# A Deep Similarity Metric Method Based on Incomplete Data for Traffic Anomaly Detection in IoT
## 4 Experiments
This is because the soft labels predicted in the first stage are not accurate, this directly affects the performance of transfer learning in the second stage. The comparison of testing accuracy proposed method, DCGAN, and AutoEncoder is shown in Figure 9. The accuracy curve of the proposed method is the curve of the adaptive layer 2048 in last  
Figure 8: Transfer learning with different adaptive layers: (**a**) Fine-tuning with different adaptive layers in the first stage; (**b**) Transfer learning with different adaptive layers in the second stage; Different lengths of adaptive fully connected layers were tested in both stages. Transfer learning with adaptive layers 2048 achieves best results. Figure 7: The first stage fine-tuning with different layers. When fine-tuning our network in the first stage, six situations were tested. The layers in the legend indicate that these layers were trained while the parameters of other layers were fixed during fine-tuning. Fine-tuning only block4 and fc achieves best classification results. experiment in Figure 8. Because the label generation process of the incomplete data is simultaneous with the first stage of fine-tuning, there is no more extra time consumption. The DCGAN is implemented by the methods in [24]. The labeled anomalies described in Figure 6 are used to train the discriminator and the generator. After 800 iterations, more than a thousand images are generated on these categories. Because most generated images are too similar to the original image, only a few images (2 cars, 8 cones, 3 trucks, and 8 types) are selected as the complementary samples to differ from the original training set for subsequent training. The mini-batch gradient descent (MBGD) method is employed to optimize the objective problem. The batch size is set to 4 and the learning rate of the fine-tuned parameters is set to 0.0002. The momentum is set to 0.5. It takes 4152 s for the DCGAN method to generate extra training samples for the second transferring stage. The AutoEncoder is implemented by the methods in [28]. The labeled anomalies introduced in Figure 6 are used to train the AutoEncoder. We consider ResNet as the feature extraction method. The extracted features of training samples are considered as the input data matrix of the encoder, the parameters of the projection are trained by the reconstruction error. After training, the features of the train set and the features from the unlabeled set are all input into the encoder to get the semantic features. We use the semantic features of each category to cluster and generate the center of each category in the semantic space. The unlabeled features from ResNet then are projected to the semantic to get the annotation by \(\underset{i\in\{car,truck,cone,type\}}{\operatorname{argmin}}\left\|s_{unlabel} -c_{i}\right\|_{2}\), where \(s_{unlabel}\) is the semantic features of unlabeled data and \(c_{i}\) is the clustering center. The size of the raw features output from ResNet is 2048 and the size of the semantic space is 200. It takes 134 s for the AutoEncoder method to extract deep features, train the encoder and decoder, and make clustering. In the second transferring stage, the batch size is set to 16 while the learning rate of the fine-tuned parameters is set to 0.0002 for the three methods. The result of the proposed method is shown in the blue curve and the highest accuracy rate reaches 0.953. The curve of the method using DCGAN is shown in orange. The maximum accuracy achieved was 0.929. The method performed with AutoEncoder is shown by the green curve. Its testing accuracy can run up to 0.898. Compared with the final stable accuracy, the proposed method is 3 percentage points higher than DCGAN and 5 percentage points higher than the AE method. The comparison of all the performances of the three methods is shown in Table 2.  
Figure 9: Comparison of testing accuracy of the proposed method, DCGAN, and AutoEncoder in second transferring stage. The batch size is set to 16 while the learning rate of the fine-tuned parameters is set to 0.0002.