  In the neutral hydrogen (HI) intensity mapping (IM) survey, the foreground
contamination on the cosmological signals is extremely severe, and the
systematic effects caused by radio telescopes themselves further aggravate the
difficulties in subtracting foreground. In this work, we investigate whether
the deep learning method, concretely the 3D U-Net algorithm here, can play a
crucial role in foreground subtraction when considering the systematic effect
caused by the telescope's primary beam. We consider two beam models, i.e., the
Gaussian beam model as a simple case and the Cosine beam model as a
sophisticated case. The traditional principal component analysis (PCA) method
is employed as a comparison and, more importantly, as the preprocessing step
for the U-Net method to reduce the sky map dynamic range. We find that in the
case of the Gaussian beam, the PCA method can effectively clean the foreground.
However, the PCA method cannot handle the systematic effect induced by the
Cosine beam, and the additional U-Net method can improve the result
significantly. In order to show how well the PCA and U-Net methods can recover
the HI signals, we also derive the HI angular power spectra, as well as the HI
2D power spectra, after performing the foreground subtractions. It is found
that, in the case of Gaussian beam, the concordance with the original HI map
using U-Net is better than that using PCA by $27.4\%$, and in the case of
Cosine beam, the concordance using U-Net is better than that using PCA by
$144.8\%$. Therefore, the U-Net based foreground subtraction can efficiently
eliminate the telescope primary beam effect and shed new light on recovering
the HI power spectrum for future HI IM experiments.
