# A Sensor Drift Compensation Method with a Masked Autoencoder Module
## 2 Materials and Methods
### Proposed Method  
In the proposed method, a deep learning model is trained to estimate gas concentrations by concatenating a calibration feature vector which contains sensor drift information to input sensor data. By training the model with a calibration feature vector, it learns to estimate gas concentrations by correlating the input sensor data and sensor drift information, making the model robust to sensor drift without fine-tuning. This methodology of prompt learning, i.e., training a neural network with context information, has shown to be effective when learning a robust model without fine-tuning for new data [19; 20; 21]. To extract good sensor drift features, we design a masked-autoencoder-based encoder, the CFE, which is  
Figure 1: (**a**) Conventional neural network (**b**) Neural network with a prompt that is the calibration feature vector generated from CFE, which is concatenated with a sensor signal. trained with past transfer samples to generate calibration feature vectors. The main aim of masked autoencoders in computer vision tasks is to remove random patches in an input image by masking and training an autoencoder model to reconstruct the original image. Masked autoencoders have been proven to produce complex, holistic reconstructions that lead to a good performance in many computer vision tasks [33]. We applied this idea to design a CFE to extract calibration feature vectors, as illustrated in Figure 2. After the CFE is trained, we trained a neural network that estimates gas concentrations only once with past sensor data concatenated with a calibration feature vector produced by the CFE. The CFE's procedure is illustrated in Figure 1b. The input data for the CFE are transfer samples which are composed of 128-dimensional sensor signals and corresponding concentration values. The transfer sample in the \(i\)-th data is denoted as \(S_{i}\), which is \(\{C_{i},G_{i}^{1},G_{i}^{2},G_{i}^{3},\ldots,G_{i}^{k}\}\), where \(G_{i}^{j}\) denotes the \(j\)-th value of sensor signals in the \(i\)-th data and \(C_{i}\) denotes the concentration value in the \(i\)-th data. In our case, \(k\) is 128 since the sensor signal sample from the E-nose is represented by a 128-dimensional feature vector. The mask is a 129-dimensional vector consisting of 0s and 1s, which is then multiplied by the Hadamard product with each batch of training data. For the input data, 75% of the gas sensor data are masked out and this mask is generated randomly for each batch while the concentration value remains the same. The target is the same data as the original input data before masking, and the masked autoencoder is trained to reconstruct the target from the masked data. Thus, the objective function to be minimized is the reconstruction error between the input data and the reconstructed data as follows:  
\[L_{MSE}=\frac{1}{B}\sum_{i=1}^{B}\|S_{i}-\hat{S_{i}}\|^{2},\]  
where \(S_{i}\in\mathbb{R}^{129}\) and \(\hat{S_{i}}\in\mathbb{R}^{129}\) are the \(i\)-th transfer sample and the \(i\)-th reconstructed output in each batch, respectively, and \(B\) is the number of data included in the batch. When the training is complete, the encoder part is extracted and used as a module to produce calibration feature vectors from new transfer samples. This procedure is illustrated in Figure 3. The designed masked autoencoder includes 5 layers with 129, 64, 32, 16, and 8 nodes sequentially at the encoder and 5 layers with 8, 16, 32, 64, and 129 nodes sequentially at the decoder. The latent space dimension is \(n\) and transfer samples from dataset-A are used for training. The training, validation, and test data are partitioned in a 7:2:1 ratio and all samples are normalized using standard normalization with the mean and standard deviation of the training set. For training, we use the Adam optimizer, the ReLU activation  
Figure 2: Architecture of the designed masked autoencoder. The dimension of the input data is 129 since it is comprised of a 128 dimension sensor signal and a corresponding concentration value.