# ResnetCPS for Power Equipment and Defect Detection
## 3 Method
### Shared Layer Complexity  
The time complexity of repeating blocks can be represented as follows:  
\[TIME\sim\mathcal{O}(N\times M^{2}\times K^{2}\times C^{2}) \tag{4}\]  
where \(N\) is the number of repetitions in the convolution blocks, \(M\) is the size of the feature map, \(K\) is the size of the convolution kernel, and \(C\) is the number of convolution kernels in each layer, which is also the number of channels in the feature map. This formula represents the number of convolution operations in each layer.  
Figure 2: The 4 th stage of the 152-layer ResnetCPS.  
If no shared units are added to the repeated blocks, its spatial complexity can be represented as follows:  
\[SPACE\sim\mathcal{O}(N\times K^{2}\times C^{2}) \tag{5}\]  
This equation represents the number of parameters for each convolutional kernel layer.  
We use time complexity divided by spatial complexity to represent the number of calculations a single parameter participates in during each forward propagation of the model. The number of calculations without adding shared units is as follows:  
If a shared unit is added to a repeated block, its spatial complexity can be represented by the following equation:  
\[SPACE^{*}\sim\mathcal{O}(N\times K^{2}\times(C-C_{share})^{2}+K^{2}\times C_{ share}^{2}) \tag{6}\]  
where \(C_{share}\) is the number of shared convolution kernels in each layer.  
\[C_{share}=\alpha C \tag{7}\]  
In repeated blocks, regardless of whether shared units are added or not, the time complexity remains unchanged, that is, the number of convolution operations in each layer remains unchanged. According to the definition, the time complexity of the convolutional layer divided by the spatial complexity can calculate the average number of times the convolutional kernel participates in convolution operations during forward propagation.  
\[Count =\frac{TIME}{SPACE} \tag{8}\] \[\sim\mathcal{O}(\frac{N\times M^{2}\times K^{2}\times C^{2}}{N \times K^{2}\times C^{2}})\sim\mathcal{O}(M^{2})\]  
If a shared unit is added to a repeated block, the number of times a single parameter participates in the forward propagation of the model is as follows:  
\[Count^{*} =\frac{TIME}{SPACE^{*}} \tag{9}\] \[\sim\mathcal{O}(\frac{N\times M^{2}\times K^{2}\times C^{2}}{N \times K^{2}\times C^{2}\times(1-\alpha)^{2}+K^{2}\times\alpha^{2}C^{2}})\] \[\sim\mathcal{O}(\frac{N\times M^{2}}{(1-\alpha)^{2}N+\alpha^{2}})\]  
Parameters can affect the size of memory occupied by the model. The more parameters there are, the larger the final model will be. It can be seen that adding shared units reduces the complexity of the model space. The number of times \(\alpha\) parameter participates in forward propagation of the model will affect the updating intensity of the parameter during error backpropagation. In other words, the more calculations it participates in, the stronger the error backpropagation. Through comparison, it can be seen that adding a shared unit will increase the number of calculations that a single parameter of the model participates in. Therefore, the average number of updates for each parameter will be more frequent. This is different from simply increasing the training step size, which can effectively improve training efficiency. The formula indicates that two parameters will have an impact on the scale and efficiency of the model. The impact of normalization layer, activation layer, short links, etc., on model performance is not coupled with shared units, so they are ignored when analyzing complexity. They also participate in training and computation, which weakens the effectiveness of parameter participation in training.