## 3 Materials and Methods
### Sample Associative Learning  
To explore the correlation between multiple sample features, the model introduces a self-attention mechanism to automatically learn the correlation between samples, captures the feature space's internal structure, and uses a convolutional network to construct a sample embedding to express the relationship between data samples. Given a set of input samples \(X=[x_{1},\ldots,\ x_{N}]\in R^{m\times N}\), the self-attention mechanism is used to learn the sample \(x_{i}=[x_{i}^{1},\ldots,x_{i}^{m}]\in R^{m}\) relationship between traffic characteristics. Self-attention maps samples to three different feature spaces, resulting in three vectors (query vector \(q_{i}\in R^{D_{k}}\), key vector \(k_{i}\in R^{D_{k}}\), and value vector \(v_{i}\in R^{D_{v}}\)):  
\[Q =W_{q}X\in R^{D_{k}\times N} \tag{2}\] \[K =W_{k}X\in R^{D_{k}\times N}\] (3) \[V =W_{v}X\in R^{D_{v}\times N} \tag{4}\]  
where \(W_{q}\in R^{D_{k}\times D_{x}}\), \(W_{k}\in R^{D_{k}\times D_{x}}\), \(W_{v}\in R^{D_{v}\times D_{x}}\) are the parameter matrix of feature mapping, and the \(Q=[q_{1},\ldots,q_{N}]\), \(K=[k_{1},\ldots,k_{N}]\), \(V=[v_{1},\ldots,v_{N}]\) matrix consists of the query vector, key vector and value vector, respectively. The purpose of setting \(Q\), \(K\), and \(V\) is to find the correlation coefficient with other features by calculation, calculate a weight for each feature, and then obtain a weighted result to judge the relationship between each feature and other features. At most, the detection efficiency of traffic is improved by learning the information in these attention values. The main work of self-attention is to calculate the dot product of the query \(Q\) and all \(K\), scale it, derive the weight of the value \(V\) through the softmax function, and then multiply the value \(V\) and the weight to obtain the attention value:  
\[\mu_{n} =att((K,V),q_{n}) \tag{5}\] \[=\sum_{j=1}^{N}a_{nj}v_{j}\] (6) \[=\sum_{j=1}^{N}softmax(s(k_{j},q_{n}))v_{j}\] (7) \[=\sum_{j=1}^{N}\frac{exp(s(k_{j},q_{n}))}{\sum_{z}exp(s(k_{z},q_{ n}))} \tag{8}\]  
among them, \(j,n\in[1,N]\) is the position of the input vector and the output vector sequence; \(a_{nj}\) represents the weight value of the nth output concerned with the jth input; \(q_{n}\) represents the query vector of the nth input sample; \(k_{j}\) represents the key of the jth input; \(v_{j}\) represents the value of the jth input, which contains the input information. Therefore, the calculated attention value is equivalent to the attention value between the ith sample and the 1 st, 2 nd, and \(i\)th inputs, that is, the correlation between each input. After obtaining the calculated attention value \(\mu_{i}\), map \(\mu_{i}\) to a new feature space to obtain the embedding vector \(e_{i}\in R^{D_{s}\times k}\):  
\[e_{i}=softmax\big{(}\bar{f}(\mu_{i})\big{)} \tag{9}\]  
where \(\bar{f}(\mu_{i})\) is the feature mapping function. After the above calculation, the embedding vector \(e_{i}\) is finally obtained, and \(E=[e_{0},\ldots,e_{N}]\in R^{D_{s}\times k\times N}\) is the sample embedding matrix composed of the embedding vectors. In this paper, the mapping function we choose is the convolutional neural network (CNN).