## 4 Methods
### Convolutional Neural Network (CNN)  
The receptive field (RF) study provides the theoretical basis of the CNN's local perception. CNN consists of layer data, hidden layer, and output layer. The hidden layer includes convolution layer, pooling layer, activation layer and fully connected layer. As the core of CNN, the convolution layer, which is prompted by the RF, and computes the convolution of the data from input layer with filters or kernels to extract high-level spatial characteristics. The main function of the pool layer is down-sampling to reduce the number of features. Convolution operations cannot only improve the original features of the data, but also reduces the data's noise [29].  
In this paper, we use 1D convolution method in our analysis. The convolution of the input sequence \(x\), at a time \(t\) is represented as:  
\[y_{k}=f\left(\sum_{i=1}^{W}\left(w_{i}\times x_{t-k+1}\right)+b_{t}\right), \tag{2}\]  
where \(y_{k}\) is the output feature at time t, \(f\left(x\right)\) is a nonlinear activation function, \(w_{i}\left(i=1,2,...,m\right)\) is the filter or kernel of length \(W\) and \(b_{t}\) is a given offset vector at time \(t\).  
The outstanding effect of extracting spatial features at CNN makes it applicable to time series. Usually, the kernel of convolution is two dimensions. To apply CNN for real-time detection and identification of anomalous sensor behaviour, a fixed-width sliding window, is inserted on input data from all sensors measuring the same quantity, either directly, where conversions or combination with other sensors may be necessary to infer the quantity. The new observations are gathered from sensors at each epoch, and from the sliding window shifts that includes the latest observations. Thus, the input to the CNN during a CAV trip is a series of continuous feed of raw sensor data. Therefore, the CNN allows for a holistic view of multiple sensors simultaneously, by incorporating information from other sensors over time to help detect and identify anomalous values. Since the goal is to detect and identify anomalous behaviour, training of the model for each sensor is implemented using the labelled sensor readings. That is, if there is an anomalous behaviour relating to a given sensor the response variable is either 0 or 1. Different models are trained to detect anomalous behaviour for each sensor, a logical OR operator on the outcomes of the model decides whether or not an anomalous behaviour is observed among all sensors. The architecture in Figure 4 is adopted in the course of the experiment in this work to optimized anomaly detection and identification efficiency on a validation set. This architecture involves three max-pooling and convolution layers. To train the CNN model, a random dropout rate of 0.1 and a batch size of 128 are employed. Additionally, batch normalization and rectified linear unit (ReLU) activation functions are used in layers as shown in Figure 4, and Adam optimizer for TensorFlow is implemented in Python for the binary cross entropy minimization.  
The following parameters are implemented for the Adam optimization; learning rate, \(\alpha=0.001\) fuzz factor \(\epsilon=10^{-8}\) and \(\beta 1=0.9,\beta 2=0.99\). Furthermore, to reduce the chance of over-fitting, early stopping is introduced to track validation set accuracy with a duration of 200 epochs.