# Multi-View Gait Recognition Based on a Siamese Vision Transformer
## 3 SMViT and the Gradually Moving-View Training Method
### Gradually Moving-View Training Method  
To develop the multi-view gait recognition model SMViT, this article designs a brand new, suitable, multi-view gait-recognition method; that is, the gradually moving-view training method. The training strategy of this method differs between the perspective feature relationship calculation module and the classification module.  
In the characteristic view relationship calculation module, SMViT uses convolution and dual-channel VIT to extract the gait characteristics. To better calculate the difference between the 90\({}^{\circ}\)- and non-90\({}^{\circ}\)-perspective characteristics, the same pre-training weights are used to calculate the characteristics tensor of the perspective. Because the purpose of this module is to calculate the perspective characteristic tensor, not the classification, the pre-training weight of the last two layers of the network module needs to be eliminated. The specific training steps are shown in Algorithm 1.  
Figure 3: PFC block and IT block.  
In the classification module, the tensors of the gait characteristics of the different views after conversion should be identified and classified. Therefore, starting with the weight of the 90\({}^{\circ}\) model with high accuracy, training is undertaken in two directions of 0\({}^{\circ}\) and 180\({}^{\circ}\). That is, a training weight of 90\({}^{\circ}\) is used as the initial weight of the model when training 72\({}^{\circ}\) and 108\({}^{\circ}\) gait data. When training at 54\({}^{\circ}\) and 126\({}^{\circ}\), the training weights of, respectively, 72\({}^{\circ}\) and 108\({}^{\circ}\) are loaded and so on. This part uses a cross-entropy loss function as the method of loss calculation as shown in formula 8. The specific training steps are shown in Algorithm 2.  
\[Loss(output,class)=weight_{[class]}(-output_{[class]}+\log{(\sum_{j}e^{output _{j}})}) \tag{8}\]  
Here, \(output\) is the prediction result, \(class\) is the actual label of this sample, and \(output_{[class]}\) represents the element of the \(class\) position in \(output\), that is, the predicted value of the real classification. Finally, \(weight_{[class]}\) is a weight parameter.  
```
Input: CASIA B gait dataset. Step 1: First, the 90\({}^{\circ}\) gait data are transformed and recognized (at this time, there is no change in the characteristics of the perspective), and the parameter weight is saved. Step 2: The weight parameters obtained in step 1 are loaded to the classification module, the gait dataset (such as 72\({}^{\circ}\) and 108\({}^{\circ}\)) of the adjacent perspective is trained, and the parameter weight is saved. Step 3: The characteristic relationship tensor between the two perspectives is matched and the parameter weights obtained in the previous step are loaded into the model. Step 4: The trained perspective weight is loaded to the model, the gait dataset of adjacent non-90\({}^{\circ}\) perspectives is trained, and the weight parameters are saved. Step 5: The classification layer and the regression layer are used to identify and classify the characteristic tensor of the view. Step 6: Push in two directions (90\({}^{\circ}\)\(\rightarrow\)0\({}^{\circ}\) and 90\({}^{\circ}\)\(\rightarrow\)180\({}^{\circ}\)), and repeat steps 3, 4, and 5. Output: The gait recognition model SMViT.
```  
**Algorithm 1**Process of training the characteristic view relationship calculation module.