The problem of determining surface shape from shading is formulated in terms of Bayesian estimation. The goal is to select an estimate of surface shape that best fits some criterion on the posterior probability of the surface conditional on the image data. This conditional probability is a function of the imaging function and the prior probability of the surface. A gradient descent technique is used to compute the best linear estimator of the mean of the conditional distribution from a set of random fractal surfaces and their images. Simulations show that the derived estimator works well for a wide range of surfaces, including non-fractals. Once learned, the estimator could be used to implement a fast, non-iterative parallel device for estimating shape from shading with arbitrary light source directions. The estimator has similar perceptual deficits to human observers. In particular, it exhibits a loss of coarse-scale surface shape, while accurately reconstructing fine-scale details.