# Convolutional-Neural-Network-Based Hexagonal Quantum Error Correction Decoder
## 3 Designing a Machine-Learning-Based Decoder for the Heavy Hexagonal Code
### Convolutional-Neural-Network-Architecture-Based Decoder  
A convolutional neural network is a type of artificial neural network, usually used for data classification problems. In machine learning [37; 38], we can reduce the decoding problem to a classification problem. It is a deep learning algorithm mainly composed of three structures: convolution, pooling, and activation. The characteristics of the neural network are defined by the convolutional layer, and the error information between qubits can be transmitted and maintained through the convolutional layer. The two-dimensional convolution operation is defined as follows:  
\[z_{ij}=\sum_{k=l-1}^{f,f}w_{kl}x_{k^{\prime}l^{\prime}}, \tag{9}\]  
\[k^{\prime}=k+i-\frac{f+1}{2},l^{\prime}=l+j-\frac{f+1}{2}, \tag{10}\]  
Figure 2: The figure displays the circuit diagram for \(X\)-type and \(Z\)-type parity check measurements of the heavy hexagonal code. Yellow circles represent data qubits, black circles represent measurement qubits, and white circles represent flag qubits. Two flag qubits (white circles) are used to measure weight-four \(X\)-type gauge generators, while one flag qubit is used to measure the weight-two \(Z\)-type gauge generators. \(z_{i}\) represents the feature map. \(w\) is an array of weights that make up the filter, and \(x\) represents the input matrix. \(k\) denotes the row index of the input matrix, which is used to traverse the elements of the input matrix. Due to the grid layout of the heavy hexagonal code and the correlation between qubit vertices, CNN is considered as a decoding method for the heavy hexagonal code [39; 40]. Additionally, the syndrome measurement information of the heavy hexagonal code will serve as the input of the fully connected neural network. The ideal error recovery operator can be obtained by mapping the input feature space through the fully connected layer to achieve classification accuracy. We utilize the topological properties of the heavy hexagonal error correction code to map the heavy hexagonal-coded image data into the CNN input, and for each hexagonal vertex lattice, it is mapped to the corresponding position in the 2D square lattice according to its coordinate information. In the convolutional layer, a certain size of convolutional kernel is selected to perform the convolutional operation on the input data, and the output value is used to determine whether the classification is correct or not; if the output value is +1, it means that the output layer is classified correctly, and if the output value is \(-1\), it means that the classification is wrong. In our experiment, we first train the neural network with smaller data and coding distance, and then expand the coding distance when the training threshold is close to our desired optimal threshold [41; 42]. However, as the coding distance increases, the training time becomes longer and the performance requirements of the machine become higher. Therefore, various conditions of the CNN network structure must be optimized to reduce the cost of training. The weights in the neural network play a decisive role in the training results. As shown in Figure 3, the convolutional neural network can use the backpropagation algorithm to adjust the network weights to achieve the training results. As we know, machine learning methods are mainly divided into supervised learning and unsupervised learning [43; 44; 45]. In our CNN model, the convolutional neural network is mainly used to supervise randomly generated errors and their corresponding \(X\) and \(Z\) stabilizer information and infer the qubit and error type of the error based on the stabilizer information. Considering that the categorical cross-entropy loss function performs well in classification problems, it is consistent with our neural network. Therefore, we used the classification cross-entropy loss function to ensure that each classification cross-entropy value was as close to the true value as possible.