# Parameter Optimization Based BPNN of Atmosphere Continuous-Variable Quantum Key Distribution
## Appendix C Back-Propagation Neural Network  
The back-propagation neural network (BPNN) is the most elementary and widely used neural network. Its output result adopts forward propagation while the error takes in back propagation. The feedforward neural network refers to the hierarchical arrangement of neurons, which is made up of input layer, hidden layer and output layer. Neurons in each layer of this neural network only receive input from neurons in the previous layer, and the latter layer has no signal feedback to the former layer. Each layer converts the input data to some extent, and then utilizes the outcome as the input of the following layer up to the eventual outcome. The back propagation is used to adjust the network weights and thresholds during training, which needs to be supervised. When your network is not well trained, the output must be different from what you think; then, we will get a deviation, and the deviation of one level forward, layer by layer to get the error \(\delta^{(i)}\). This is the feedback. The feedback is used to find the partial derivative, which is typically used for gradient descent. Then, the gradient descent is applied to acquire the minimum value of the cost function, so that the error between the expectation and the output can be reduced as much as possible. The flow diagram of the back-propagation neural network algorithm is shown in Figure 14, it can be roughly divided into five steps:  
**Step 1: Initialize network weights and offsets. ** We know that, after training, the connection weight (network weight) between different neurons is diverse. Therefore, in the initialization stage, we give each network connection weight a small random number (generally \(-\)1.0-1.0 or \(-\)0.5\(\sim\)0.5), and each neuron has a bias (bias can be regarded as the weight of each neuron), which will also be initialized to a random number. **Step 2: Forward propagation. ** Enter a training pattern and figure out the output result of each and every neuron. Each neuron works out a linear combination of its inputs. The calculation formula of the activation value of each neuron in the hidden layer is indicated as  
\[\alpha_{j}=\sum_{i=1}^{m}v_{ij}x_{i}. \tag{15}\]  
Then, the output value of the \(j\)-th neuron in the hidden layer is \(f(\alpha_{j}-\gamma_{j})\), where \(f(x)=\frac{1}{1+e^{-x}}\). The input value that the \(k\)-th neuron received in the output layer is  
\[\beta_{k}=\sum_{j=1}^{n}w_{jk}b_{j}. \tag{16}\]  
In the end, the final output of the \(k\)-th neuron in the output layer is  
\[y_{k}=f(\beta_{k}-\theta_{k}). \tag{17}\]  
**Step 3: Calculation error and back propagation. ** This stage is the learning process of the algorithm. In the learning process, we hope that the output of the algorithm can be consistent with our real value to the greatest extent. When the output value and real value is different, there will ineluctably be an error. The lesser the error, the better the prediction effect of the algorithm. Obviously, the input data are known, and the variables are only those connection weights that will affect the output. For training example \((x_{h},y_{h})\), suppose the output of the neural network is \(\widehat{y}_{h}=(\hat{y}_{1}^{h},\hat{y}_{2}^{h},\ldots,\hat{y}_{p}^{h})\). Therefore, the mean square error in the training example \((x_{h},y_{h})\) is expressed as  
\[E_{h}=\frac{1}{2}\sum_{k=1}^{p}(\hat{y}_{k}^{h}-y_{k}^{h})^{2}. \tag{100}\]  
Based on the gradient descent strategy, the BP algorithm adjusts the parameters in the direction of the negative gradient of the target.