## 4 Behavior Detection Model Construction
### Hyper-Parameters and Evaluation Metric  
This article built a SE-ResNet50 model based on the PyTorch deep learning framework, with the hardware configuration of NVIDIA RTX A5000 24 GB GPUs. The network was optimized using the Adam algorithm, with an initial learning rate (lr) of 0.001, and the batch size of the dataset was set to 128 (when batch size is set too small, it causes greater fluctuations during training and slower convergence). The model was trained for 50 epochs, and Table 4 summarizes the values of some hyper-parameters in our training stage. The PETA+ self-made dataset used for network training was randomly divided into training and test sets at a ratio of 6:4, with a total of 10,200 images in the training set and 6800 images in the test set. The training set was used for model training, while the test set was used for performance validation of the model.  
Gender division is a binary classification problem, while age and behavior division belong to multi-classification problems. For binary classification problems, the accuracy, precision, recall, and F1 score can be used as evaluation indicators of model performance. For multi-classification problems, each category is usually transformed into multiple binary classification models, calculated separately, and then summarized using certain criteria.  
Accuracy: the proportion of correctly predicted samples to the total number of samples, calculated as follows in Equation (1).  
\[\text{Accuracy}=\frac{\text{TP}+\text{TN}}{\text{TP}+\text{TN}+\text{FP}+ \text{FN}} \tag{1}\]  
Precision: the proportion of samples correctly predicted as positive to the number of samples predicted as positive. The calculation formula is as follows in Equation (2):  
\[\text{Precision}=\frac{\text{TP}}{\text{TP}+\text{FP}} \tag{2}\]  
Recall: the proportion of samples correctly predicted as positive to the actual number of positive samples, also known as sensitivity or the true positive rate. The calculation formula is as follows in Equation (3):  
\[\text{Recall}=\frac{\text{TP}}{\text{TP}+\text{FN}} \tag{3}\]  
F1 score: an indicator that comprehensively considers accuracy and recall and is the harmonic mean of precision and recall. The higher the F1 score, the better the performance of the model. The calculation formula is as follows in Equation (4):  
\[\text{F1}=\frac{2\times\text{Precision}\times\text{Recall}}{\text{Precision}+ \text{Recall}} \tag{4}\]  
where true positive (TP) represents the number of positive labels correctly predicted; true negative (TN) represents the number of negative labels correctly predicted; false positive (FP) represents the number of negative samples incorrectly predicted; and false negative (FN) represents the number of positive samples incorrectly predicted.  
\begin{table}
\begin{tabular}{c c} \hline \hline
**Hyper-Parameter** & **Setup** \\ \hline Batch size & 128 \\ Learning Rate & 0.001 \\ Epochs & 50 \\ \hline \hline \end{tabular}
\end{table}
Table 4: Hyper-parameters for model training.  
By observing Figure 9a-c,g,h, it can be seen that when the number of iterations was within 10, the errors of the training and test sets of pedestrian attributes and behaviors quickly decreased, and the accuracy quickly rose; when the number of iterations reached about 30, at this time, the error value of the training set was still decreasing, while the error value of the test set tended to converge and reach the lowest value, and the accuracy also gradually converged to the maximum value; and when the number of iterations was greater than 30, the error value of the training set still decreased and the accuracy still increased, but at this time, the error value of the test set increased and the accuracy increased slowly, indicating that overfitting occurred in the model at this time. Therefore, this model can find optimal model parameters around 30 iterations.  
According to Table 5, the accuracy of model's recognition was above 83%, and the model achieved good results and could be used for behavior detection in subsequent actual scenarios.