# A Deep Similarity Metric Method Based on Incomplete Data for Traffic Anomaly Detection in IoT
## 4 Experiments  
In the previous section, we describe the channel attention model based on Siamese architecture for traffic anomaly classification, our deep transfer learning method and background modeling method for anomaly detection. In this section we first introduce the incomplete data for our experiments. Then several experiments are implemented to validate the effectiveness of the proposed model and transfer learning method. After testing under various conditions, we finally find that the proposed method is superior to DCGAN method and AutoEncoder method in practical application. Finally, we show the anomalies detected and classified in real traffic data-sets. The experiments are all performed by Pytorch (Pytorch 0.4.1: Facebook, Menlo Park, CA, USA) deep learning framework on Windows 10 Pro (Microsoft, Redmond, WA, USA) operating system. The experimental platform is equipped with Intel(r) Core(TM) i7-6700 CPU (Intel, Santa Clara, CA, USA) @ 3.40 GHz, 32 GB RAM and NVIDIA GeForce GTX 1060 GPU (NVIDIA, Santa Clara, CA, USA). Part of the training samples are shown in Figure 6. In the process of transfer learning, 39 images were selected as the labeled anomalies for training (11 cars, 10 trucks, 10 cones, and 8 types), 72 images were selected as unlabeled data, 746 images were considered as the testing data (199 cars, 225 trucks, 210 cones, and 112 tyres). The target is to transfer from labeled data to unlabeled data. The generalization ability depends on the performance of the model on testing data-sets. The first stage fine-tuning with different layers is shown in Figure 7. According to the overall framework of the proposed model, the layers are divided into six parts: conv1, block1, block2, block3, block4, and fc layer. The contents displayed in the legend of each line represent the layers fine-tuned while other layers do not list in the legend denote that their parameters are fixed during the first stage fine-tuning. The adaptive moment estimation (Adam) method is employed to optimize the objective problem. The batch size was set to 16 and the learning rate of the fine-tuned parameters is set to 0.0001. The model is trained for 100 epochs. It is obvious from the figure that fine-tuning only the fully connected layer leads to poor performance on the testing set. No significant improvement is achieved when fine-tuning all layers. The two situations above both converge at a very slow rate. Fine-tuning only block4 and fc achieves fastest convergence rate and highest accuracy. Therefore, the parameters of conv1, block1, block2, and block3 are fixed in the subsequent experimental stages. Figure 6: Several categories of training samples (**a**) cars (**b**) trucks (**c**) cones (**d**) tyres. 11 cars, 10 trucks, 10 cones, and 8 tyres are selected as the incomplete training samples. 199 cars, 225 trucks, 210 cones, and 112 tyres. 72 images were selected as unlabeled data. The effects of different adaptive layer sizes on the performance of the model are tested in Figure 8. Six different sizes of adaptive layers (128, 256, 512, 1024, 2048, 4096) are attempted in two stages of transferring respectively. The mini-batch gradient descent (MBGD) method is employed to optimize the objective problem. The batch size is set to 16 and the learning rate of the fine-tuned parameters is set to 0.0002. The model is trained for 100 epochs. In the first stage, the model with adaptive layers with lengths of 2048 and 4096 have the fastest convergence speed. The adaptive layers with a length of 2048 achieve the highest accuracy (just over 0.9). The curve of adaptive layer 4096 is next only to adaptive layer 2048. In the second stage, the model with adaptive layers length 4096 has the fastest pace of convergence. Finally, the adaptive layers of length 2048 achieved the highest accuracy (just over 0.95). The accuracy curves of adaptive layers 128 and 256 in the second stage decreases compared to their corresponding curves in the first stage.