Frequency hopping technology is a kind of spread spectrum communication, the signal frequency will be randomly hopped in a relatively wide band during the communication process, so as to avoid interference and interception by the enemy, and due to its secrecy performance and anti-multipath fading performance and other characteristics make it is widely used in the field of military communications. The identification of the modulation type of the intercepted frequency hopping signals in electronic information warfare is very important for the subsequent study and processing of the signals. In this paper, the Transformer algorithm is introduced into the field of modulation recognition, and the average recognition rate is 1.82% higher than ResNet50 by experimental comparison. For the interference of pre-processing cropping and patch merging in Swin Transformer on the clarity of time-frequency images, this paper adds Fast-NLM denoising to improve the average recognition rate by 0.8%. In addition, for the problem of attention scattering in Swin Transformer, this paper adopts a variable attention model, and the key sampling points around the reference points on the feature map are moved closer to the feature area by the calculation of offset, so that the feature representation can be better obtained. The experimental results show that the recognition rate of the improved model is 2.35% higher than that of the original model, the perception ability of some modulated signals is enhanced, and the addition of denoising can improve another 0.840%.