In this paper, we use Sina Weibo text as the main experimental dataset, and propose a coding method suitable for selfoptimization of convolutional neural networks. Our coding method encodes each CNN framework using a hybrid double nonnumeric encoding by treating each layer as a chromosome and the parameters in each layer as a gene segment respectively, and selection, crossover and mutation algorithms are devised for CNN networks. We also propose a genetic algorithm based on sentiment analysis algorithm (GACNN) which combines genetic algorithm (GA) with convolutional neural network. The experiment and comparative analysis of GACNN and traditional algorithms demonstrates the selfoptimization of our method.