  Accurately measuring magnetic fields is essential for magnetic-field
sensitive experiments in fields like atomic, molecular, and optical physics,
condensed matter experiments, and other areas. However, since many experiments
are conducted in an isolated vacuum environment that is inaccessible to
experimentalists, it can be challenging to accurately determine the magnetic
field. Here, we propose an efficient method for detecting magnetic fields with
the assistance of an artificial neural network (NN). Instead of measuring the
magnetic field directly at the desired location, we detect magnetic fields at
several surrounding positions, and a trained NN can accurately predict the
magnetic field at the target location. After training, we achieve a relative
error of magnetic field magnitude (magnitude of error over the magnitude of
magnetic field) below 0.3$\%$, and we successfully apply this method to our
erbium quantum gas apparatus. This approach significantly simplifies the
process of determining magnetic fields in isolated vacuum environments and can
be applied to various research fields across a wide range of magnetic field
magnitudes.
