Context. The method of solar magnetic field calibration for the filter-based magnetograph is normally the linear calibration method under weak-field approximation that cannot generate the strong magnetic field region well due to the magnetic saturation effect. Aims. We try to provide a new method to carry out the nonlinear magnetic calibration with the help of neural networks to obtain more accurate magnetic fields. Methods. We employed the data from Hinode/SP to construct a training, validation and test dataset. The narrow-band Stokes I, Q, U, and V maps at one wavelength point were selected from all the 112 wavelength points observed by SP so as to simulate the single-wavelength observations of the filter-based magnetograph. We used the residual network to model the nonlinear relationship between the Stokes maps and the vector magnetic fields. Results. After an extensive performance analysis, it is found that the trained models could infer the longitudinal magnetic flux density, the transverse magnetic flux density, and the azimuth angle from the narrow-band Stokes maps with a precision comparable to the inversion results using 112 wavelength points. Moreover, the maps that were produced are much cleaner than the inversion results. The method can effectively overcome the magnetic saturation effect and infer the strong magnetic region much better than the linear calibration method. The residual errors of test samples to standard data are mostly about 50 G for both the longitudinal and transverse magnetic flux density. The values are about 100 G with our previous method of multilayer perceptron, indicating that the new method is more accurate in magnetic calibration.