Analytical formulas for calculating magnetic fields have been derived in the past for common magnet types, offering microsecond-level computational speed ideal for magnet system modeling. These formulas mostly assume perfect homogeneity of the magnetization, leading to slight deviations from real field values where material interaction plays a role. This paper introduces a physics-based neural network that reduces errors occurring from the self-demagnetization effect by an order of magnitude, maintaining fast computational speed.