# ResnetCPS for Power Equipment and Defect Detection
## 3 Method
### Convolution Operations with Cross-Layer Parameter Sharing  
The equation for the convolution operation can be expressed as follows:  
\[c_{i,j,k}^{(l)}=\sum_{m=1}^{F}\sum_{n=1}^{F}w_{m,n,k}^{(l)}a_{(i-\frac{F+1}{2} )\times s+m,(j-\frac{F+1}{2})\times s+n}^{(l-1)} \tag{1}\]  
where \(c_{i,j,k}^{(l)}\) is the convolution result of the \(i\)-th row and \(j\)-th column and \(k\)-th kernel in the \(l\)-th layer, \(w_{m,n,k}^{(l)}\) is the weight of the \(k\)-th convolution kernel's \(m\)-th row and \(n\)-th column, and \(a_{(i-\frac{F+1}{2})\times s+m,(j-\frac{F+1}{2})\times s+n,k}^{(l)}\) is the value of the \(k\)-th feature map at position \(((i-\frac{F+1}{2})\times s+m,(j-\frac{F+1}{2})\times s+n)\) in the \((l-1)\)-th layer. \(F\) is the size of the convolutional kernel, and \(s\) is the stride size, representing the step size at which the convolutional kernel slides on the input feature map. Consider bias and concatenate the outputs to obtain the output of that layer.  
\[z_{i,j}^{(l)}=b^{(l)}+\sum_{k=1}^{K^{(l)}}c_{i,j,k}^{(l)} \tag{2}\]  
where \(z_{i,j}^{(l)}\) is the convolution result of the \(i\)-th row and \(j\)-th column in the \(l\)-th layer, \(b^{(l)}\) is the bias term, and \(K^{(l)}\) is the number of convolution kernels in the \(l\)-th layer.  
We define shared convolution as the partial convolution kernels between duplicate layers or blocks being the same, with the same parameters.  
The resulting output is also concatenated from the individual outputs of each convolutional kernel. Equation (1) has been rewritten as follows:  
Figure 1: The structure of ResnetCPS152 with ratio \(=1/4\).  
\[\begin{split} z_{i,j}^{(l)}&=b^{(l)}\\ &+\sum_{k=1}^{K^{(l)}}\sum_{m=1}^{F}\sum_{n=1}^{F}w_{m,n,k}^{(l)}a_ {(i-\frac{F+1}{2})\times s+m,(j-\frac{F+1}{2})\times s+n}\\ &+\sum_{k=K^{(d)}}^{K^{(d)}}\sum_{m=1}^{F}\sum_{n=1}^{F}w_{m,n,k} ^{(d)}a_{(i-\frac{F+1}{2})\times s+m,(j-\frac{F+1}{2})\times s+n}\end{split} \tag{3}\]  
where \(K^{(d)}\) is the number of convolution kernels in the \(d\)-th layer of the duplicate blocks, and \(w_{m,n,k}^{(d)}\) is the weight of the \(k\)-th convolution kernel's \(m\)-th row and \(n\)-th column in the \(d\)-th layer of the duplicate blocks.  
Figure 2 shows the repetitive structure of the 4 th stage of the 152-layer ResnetCPS. It contains a bottleneck block repeated 35 times, marked as a black dashed rounded box. Each block is composed of a repeated three-layer network, labeled as a gray solid line rounded box, consisting of a \(1\times 1\) convolutional layer for 256 channels, a \(3\times 3\) convolutional layer for 256 channels, and a \(1\times 1\) convolutional layer for 1024 channels. When the sharing ratio is 1/4, each layer corresponds to 64, 64, and 256 channel convolutions as shared convolutions, marked with green rounded boxes. These convolution parameters distributed in different blocks correspond to the same channel, and they calculate a common gradient during training while being modified. The remaining convolution parameters are labeled with rounded boxes of different colors, and their respective gradients are computed during training. In forward calculation, the convolutional kernels of each layer are combined and calculated forward on a layer-by-layer basis. Each layer of its repeating structure has a portion of the shared parameter part that shares parameters. In forward propagation, the shared parameter part can participate in the calculation repeatedly. Shared parameter parts distributed in different layers will be simultaneously calculated and updated when calculating gradients in reverse. The proportion of this part is set as hyperparameter r in the article. The remaining components are unique convolutional kernels for each structure, which generally participate in gradient calculations.