In this paper, using a deep neural network and a genetic algorithm, an optimized digital metasurface is designed to trap sunlight in thin-film solar cells. The deep neural network is trained using full-wave numerical simulation results as the training dataset, and it is designed to predict the electromagnetic response of thin-film solar cells whose active layers are shaped as a digital metasurface. The developed neural network can predict the results much faster than full-wave solvers and therefore can be used for optimization purposes. Using the results generated by the trained neural network, an evolutionary procedure based on the genetic algorithm is developed to find the optimum structure for the digital metasurface, which provides the highest short circuit current inside the thin-film solar cell. The performance of the resultant optimum design is validated using full-wave numerical simulation illustrating a short circuit current of 15.39mA/cm2 and 13.30mA/cm2 for TE and TM polarization of the incident light, respectively. The resultant short circuit current is 2.47 and 2.13 times higher than a simple thin-film solar cell with the same amount of silicon inside, for TE and TM polarization of the incident light, respectively. To have a more comprehensive comparison, the designed optimum structure is compared with several standard shapes for the metasurface, such as star and plus sign. This comparison showed that the optimum structure provides a short circuit current which is much higher than the current achieved by standard shapes.