# Domain Generalization Model of Deep Convolutional Networks Based on SAND-Mask
## 2 Materials and Methods
### Improved SAND_Mask  
As shown in Figure 2, when SAND-Mask is used to calculate \(\sigma\) in a batch, the variance of each sample gradient needs to be calculated first, and then \(\sigma\) is calculated according to Formula (2). This method of calculating \(\sigma\) has achieved good results in the field of computer vision. The main reason lies in the field of image given the fact that the differences in data distributions between samples from different source domains can be very big. To ensure the generalization ability of the model, the model needs to be considered in calculating gradient sizes separately for each sample and then computing \(\sigma\), ultimately guaranteeing consistent gradient magnitude and direction within a batch of data. For the field of fault diagnosis, the difference in data distribution between different working conditions is caused by operating conditions. For example, in the CWRU dataset, the motor load changes from 0 HP to 3 HP, and there are four working conditions in the CWRU data set. However, the variation range of machine operating conditions is very wide. For example, assuming that the speed of bearing is 1000-2000 rpm, there are 1001 working conditions. In the case that multiple conditions cause a change in working conditions, the number of working conditions will increase with the speed of the product of the variation range of various conditions. Therefore, the total gradient variance of all samples in a batch is used to replace the gradient variance of each sample to calculate parameter \(\sigma\). By improving the method of calculating gradient variance of SAND-Mask, the problem of doubling the number of working conditions is solved and the training time of the model is accelerated. At present, some research studies are trying to solve this cross-domain consistency problem, which mainly includes two aspects: feature level and gradient level. The goal of the feature level is to generate potential variables that represent all domains and minimize  
Figure 2: SAND-Mask Calculates \(\sigma\) in a batch. risks between domains, while the goal of the gradient level is to promote a consistency of gradients across domains. In the problem of fault classification, most research studies use adversarial network, distance metric learning, and other methods to try to map data from different domains to a new feature space, reduce the differences between domains, and generalize the established model to an unknown target domain. At present, not much progress has been made for solving the cross-domain problem of fault classification by gradient levels. Compared with other generalization research studies, the generalization model based on the improved SAND-Mask method reduces the complexity of the network and speeds up the training speed of the network. We assume that the \(\left\}_{s}^{e}=\left\{x_{s,i}^{e},y_{s,i}^{e}\right.\right\}_{ecc}\) represents the source domain data and \(e\) represents the machine's running condition, with \(s,i_{e}=1,\ldots,n^{e}\), \(\left|\epsilon\right|=N_{s}\) being the number of working conditions of the source domain. We need to establish a generalization model \(y=f_{\theta}\left(x\right)\), where \(f\) represents the mapping function and \(\theta\) represents the parameters of the deep learning network in the DCNG model, where \(\theta\in\theta\subseteq\mathbb{R}^{n}\). SAND-Mask [8] adopts the geometric average of Hessian matrix. It is necessary to ensure that the gradient directions of all elements are consistent. The matrix \(m_{\tau}\left(\theta^{k}\right)\) is established by SAND-Mask to apply the SAND-Mask method to every parameter in the network. \[m_{\tau}=\max\left(0,\tanh\left(\frac{1}{\sigma}\left(\left|\frac{1}{\left| \epsilon\right|}\sum_{ecc}sign(\
abla\mathcal{L}_{e})\right|-\tau\right) \right)\right) \tag{1}\]  
\(\tau\) represents the threshold of consistency in the gradient direction of multiple conditions, \(\tau\in\left[0,\,1\right]\).