The demand for high-precision human motion recognition continues to rise. In this experiment, an active contrast coding model based on self-attention is constructed. In the self attention based active contrast coding model, the model fully takes into account the feature differences of different properties of actions, and uses a fixed sliding window to segment the human activity data of inertial sensors with different properties. Cross-validation is used to improve the generalization ability of the model and prevent the occurrence of overfitting. The generalization ability and overfitting phenomenon of the model are evaluated by using the confusion matrix index, ROC curve when each movement is positive and visualization of the model. The accuracy of the final model is 0.987, the F1 score is 0.998, and the precision is 0.987; the recall rate was 0.976, and the AUC values of ROC curves with positive movements were greater than 0.97. Through the visualization of the model, it is found that the boundary between the A3 motion and A8 motion is not clear enough, and the boundary between A18 and A15 motion is not clear enough. Perhaps increasing the amount of data will lead to a more accurate classification of sports.