When and Why Are Deep Networks Better Than Shallow Ones?