Quantum error correction technology is an important solution to solve the noise interference generated during the operation of quantum computers. In order to find the best syndrome of the stabilizer code in quantum error correction, we need to find a fast and close to the optimal threshold decoder. In this work, we build a convolutional neural network (CNN) decoder to correct errors in the toric code based on the system research of machine learning. We analyze and optimize various conditions that affect CNN, and use the RestNet network architecture to reduce the running time. It is shortened by 30%–40%, and we finally design an optimized algorithm for CNN decoder. In this way, the threshold accuracy of the neural network decoder is made to reach 10.8%, which is closer to the optimal threshold of about 11%.The previous threshold of 8.9%–10.3% has been slightly improved, and there is no need to verify the basic noise.