Three-dimensional shape recovery is an important issue in the field of computer vision. Shape from Focus (SFF) is one of the passive techniques that uses focus information to estimate the three-dimensional shape of an object in the scene. Images are taken at multiple positions along the optical axis of the imaging device and are stored in a stack. In order to reconstruct the three dimensional shape of the object, the best-focused positions are acquired by maximizing the focus curves obtained via application of a focus measure operator. In this article, Deep Neural Network (DNN) is employed to extract the more accurate depth of each object point in the image stack. The size of each image in the stack is first reduced and then provided to the proposed DNN network to aggregate the shape. The initial shape is refined by applying a median filter, and later the reconstructed shape is sized back to original by utilizing bi-linear interpolation. The results are compared with commonly used focus measure operators by employing root mean squared error (RMSE), correlation, and image quality index (Q). Compared to other methods, the proposed SFF method using DNN shows higher precision and low computational time consumption.