The initial in situ stress field is the fundamental factor causing the deformation and failure of underground engineering and is an important basis for the feasibility analysis, design, and construction of underground engineering. However, it is difficult to obtain the whole in situ stress field of large-scale underground engineering in difficult and dangerous areas by field measurement. In view of the fact that the measured in situ stress components (σxx, σyy, σzz, τxy, τxz, τyz) of Sichuan-Tibet Railway in China are linear with the buried depth, a method is proposed to solve the in situ stress by applying corresponding loads to all unit bodies in the calculation area based on BP neural network and FLAC3D. Through this method, the in situ stress of the tunnel is inverted. The results show that both the maximum principal stress and minimum principal stress increase with the increase of buried depth, and when the tunnel passes through faults or anticlines, the main stress will suddenly drop. Furthermore, compared with the results of the multiple linear regression method, it is found that the proposed method has higher accuracy; especially for the simulation of the maximum horizontal principal stress and vertical stress, the average relative error is reduced by 26.44% and 77.27%, respectively. The research in this paper can provide a new idea for the initial in situ stress inversion of engineering.