In this paper, we describe a novel use of neural networks for extracting three-dimensional shape of the objects based on image focus. The conventional shape from focus methods are based on piece-wise constant, or piece-wise planar approximation of the focused image surface (FIS) of the object, so they fail to provide accurate shape estimation for objects with complex geometry. The proposed scheme is based on representation of three-dimensional shape of FIS in a window in terms of the neural network weights. The neural network is trained to learn the shape of the FIS that maximizes the focus measure. The SFF problem has thus been converted to an ordinary optimization problem in which a criterion function (focus measure) is to be optimized (maximized) with respect to the network weights. Gradient accent method has been used to optimize the focus measure over the three-dimensional FIS. Experiments were conducted on three different types of objects to compare the performance of the proposed algorithm with that of traditional SFF methods. Experimental results demonstrate that the method of SFF using neural networks provides more accurate depth estimates than those by the traditional methods.