gravity exploration is one of the most widely used geophysical methods in geophysics exploration by measuring gravity anomalies caused by density anomalies and interpreting the underground density anomalies qualitatively and quantitatively. Because 3D inversion of physical properties can describe the study object of geological structure more precisely, it has become a conventional method for quantitative interpretation of gravity anomaly data. Based on LinkNet, the forward and inverse methods of 3D gravity anomaly are studied in this paper. The forward network is constructed on the basis of Residual network to realize the mapping from underground density anomaly to gravity anomaly data. The loss function uses MSE loss, which constrains the real gravity anomaly data and the prediction value of the gravity anomaly output of the forward network. The encoder module of the inversion network is changed to the form of dense connection, and the mapping of gravity anomaly data to underground density anomaly body is studied. The loss function uses Dice loss to constrain the similarity between the real density anomaly and the density anomaly predicted by the inversion network. The data loss and the model loss are constrained by the forward network and the inverse network to reduce the non-uniqueness of the solution. By comparing with the method of training only inversion network, it is found that the average relative error of training both forward and inversion network is lower on the conventional data set, which verifies the effectiveness of the method, the effect of the network is further verified on the random model and five conventional models. Finally, the effect of the network on real field data is tested.