The invention discloses a text sentiment classification algorithm based on a convolutional neural network and an attention mechanism. The text sentiment classification algorithm comprises the steps of1, establishing the convolutional neural network comprising multiple convolutions and multiple kinds of pooling, and using sentiment classification text for training to obtain a first model; 2, establishing the multi-head point product attention mechanism into which residual connection and nonlinearity are added, and using the sentiment classification text for training to obtain a second model; 3, conducting model fusion on the two models to obtain sentiment classification of the text. Multiple granularity, the convolutions and multiple kinds of pooling are fused into the convolutional neuralnetwork, the residual connection and the nonlinearity are introduced into the attention mechanism, and attention is calculated several times to obtain two text sentiment classification models. Through a Bagging model fusion method, a fusion model is obtained, the text is classified, the advantages that the convolutional neural network can well capture local features and the attention mechanism can well capture global information can be combined, and the more comprehensive text sentiment classification models are obtained.