# Pulse-Shape Discrimination of SiPM Array-Coupled CLYC Detector Using Convolutional Neural Network
## 3 Pulse-Shape Discrimination
### Convolutional Neural Network  
The CNN consists of three parts: the convolution layer, the pooling layer, and the fully connected layer. Local features can be extracted from signals by the convolution layer, and its calculation principle is  
\[d^{l}=f(z)=f\Big{(}W^{l}*a^{l-1}+b^{l}\Big{)}. \tag{3}\]  
The pooling layer can reduce the magnitude of parameters, and the calculation principle is  
\[a^{l}=z^{l}=pool\Big{(}a^{l-1}\Big{)}. \tag{4}\]  
The fully connected layer is responsible for parameter output, and its calculation principle is  
\[a^{l}=f(z)=f\Big{(}W^{l}\cdot a^{l-1}+b^{l}\Big{)}. \tag{5}\]  
Here, the superscript of the parameter represents the number of network layers: a is the output value, \(W\) is the weight, \(b\) is the additional bias, and \(f\) is the activation function [23]. The sample error is obtained after the Convolutional Neural Network has completed forward propagation, and then the weights are updated by gradient descent and backward propagation. The error gradient \(\frac{\partial{I}}{\partial{z^{l}}}\) of the output layer \(z\) is equal to \(\delta\), and its transmission in the fully connected layer is  
\[\frac{\partial{J}}{\partial{z^{l-1}}}=\frac{\partial{J}}{\partial{z^{l}}}* \frac{\partial{z^{l}}}{\partial{z^{l-1}}}=\Big{(}W^{l}\Big{)}^{T}\frac{ \partial{J}}{\partial{z^{l}}}f^{\prime}\Big{(}z^{l-1}\Big{)}. \tag{6}\]  
The pooling layer's transfer mode is  
\[\frac{\partial{J}}{\partial{z^{l-1}}}=upsample\Big{(}\frac{\partial{J}}{ \partial{z^{l}}}\Big{)}f^{\prime}\Big{(}z^{l-1}\Big{)}. \tag{7}\]  
The transfer mode in the convolution layer is  
\[\frac{\partial{J}}{\partial{z^{l-1}}}=\frac{\partial{J}}{\partial{z^{l}}}*rot1 80\Big{(}W^{l}\Big{)}f^{\prime}\Big{(}z^{l-1}\Big{)}. \tag{8}\]  
The \(\frac{\partial{J}}{\partial{W^{l-1}}}\) and \(\frac{\partial{J}}{\partial{W^{l-1}}}\) values are then determined according to the relationship between \(z\), \(W\), and \(b\). The weights are updated using the formula below. \[\left\{ \begin{array}{l}W^{l}(s+1)=\Big{(}1-\frac{\eta\lambda}{n}\Big{)}W^{l }(s)-\eta\frac{\partial{J}}{\partial{W^{l}}}\\ b^{l}(s+1)=\Big{(}1-\frac{\eta\lambda}{n}\Big{)}b^{l}(s)-\eta\frac{\partial{J }}{\partial{W^{l}}}\end{array} \right.. \tag{9}\]  
where \(\eta\) is the learning efficiency, \(\lambda\) is the regularization coefficient, and \(n\) is the number of training samples. The training set signal is first classified by the charge comparison method, with the neutron signal's label set to 1 and \(\gamma\) set to 0. The unknown set signal does not need to be classified. The structure of the CNN network in this study is shown in Figure 6, which includes the signal feature extraction process and the signal classification process. After passing through the convolutional (the activation function is ReLU, defined in Equation (10)) and pooling layers to extract features, the spread layer will modify the signal to a shape suitable for the input of the fully connected layer, then pass through two fully connected layers (the activation function is ReLU). Finally, at the output layer (the activation function is sigmoid, defined in Equation (11)), the output parameters corresponding to each input signal are output. The backpropagation algorithm can transfer the error between the output parameter a and the preset label of the signal and modify the structural parameters in the CNN, reducing the error between parameter a and the preset label to increase the CNN'sdiscrimination accuracy. The training ends when the accuracy rate reaches a certain value. The CNN of this study is based on the code written by MatLab. Algorithm 1 shows the algorithm flow of the CNN in this study. \[ReLU=max(0,x). \tag{10}\]  
\[sigmoid=\frac{1}{1+e^{-x}} \tag{11}\]  
[PERSON] et al. [24] observed that the input signal format of CNN was a one-dimensional vector. These researchers tried to fold the input signal of the one-dimensional vector into a two-dimensional matrix format as the input of the CNN.