## 2 Materials and Methods
### Proposed Method  
We present a deep neural network for gas source localization using the ViViT. This model takes time series gas diffusion data \(\mathbf{V}\) as the input and accomplishes gas source localization by classifying the grid where gas occurred among \(N_{C}\) grids. Transformers, which employ attention mechanisms, were initially introduced in [25] to process time series data. They have since been applied not only to natural language processing [26] but also to various fields such as image and video classification [28; 29], demonstrating a remarkable performance. Our model is designed based on the video vision transformer [30], which employs the transformer structure for video classification. The model structure comprises embedding layers, transformer encoders, and a classifier, as illustrated in Figure 2.  
Within the embedding layers, the input \(\mathbf{V}\) undergoes conversion into a sequence of tokens \(\mathbf{z}^{0}\in\mathbb{R}^{(N+1)\times d}\) expressed as  
\[\mathbf{z}^{0}=(z_{cls},\mathbf{E}x_{1},\dots,\mathbf{E}x_{N})+\mathbf{p},\]  
where \(z_{cls}\in\mathbb{R}^{d}\) represents the learned classification token [26]. Each \(\mathbf{E}x_{i}\in\mathbb{R}^{d}\) token corresponds to a tablet extracted from the video \(\mathbf{x}_{i}\in\mathbb{R}^{t\times h\times w\times C}\) and linearly projected, while \(\mathbf{p}\in\mathbb{R}^{(N+1)\times d}\) denotes a learned positional embedding. Nonoverlapping spatio-temporal tublets \(x_{i}\) are extracted from \(\mathbf{V}\). Given the tablet dimensions of \(t\), \(h\), and \(w\) for the temporal, height, and width, respectively, the total number of extracted tublets is \(N=n_{t}\times n_{h}\times n_{w}\), where \(n_{t}=\lfloor\frac{T}{t}\rfloor\), \(n_{h}=\lfloor\frac{H}{h}\rfloor\), and \(n_{w}=\lfloor\frac{W}{w}\rfloor\). Figure 3 illustrates the extraction of tublets spanning the spatio-temporal input \(\mathbf{V}\). These tublets \(x_{i}\), for \(i=1,2,\dots\)  
Figure 1: Sample (**a**) illustrates time series gas diffusion data generated by NBC-RAMS, while sample (**b**) depicts the data after preprocessing. The color bar positioned to the right of the samples indicates the value of each data point. \(N\), are linearly projected by \(\mathbf{E}\) into tokens \(\mathbf{E}x_{i}\). Subsequently, \(z_{cls}\) is prepended to these tokens, resulting in the sequence \((z_{cls},z_{1},\ldots,z_{N})\), where \(z_{i}=\mathbf{E}x_{i}\). This sequence, augmented by the learned positional embedding \(\mathbf{p}\), forms the input \(\mathbf{z}^{0}\) for the transformer encoders. The sequence of tokens \(\mathbf{z}^{0}\) passes through \(L\) transformer layers, resulting in \(\mathbf{z}^{L}\in\mathbb{R}^{(N+1)\times d}\), where the dimension of each token remains \(d\) throughout each layer. Each layer consists of multi-headed self-attention (MSA) [25], layer normalization (LN) [33], and multi-layer perceptron (MLP) blocks:  
\[\mathbf{y}^{l} =\text{MSA}\left(\text{LN}\left(\mathbf{z}^{l}\right)\right)+ \mathbf{z}^{l},\] \[\mathbf{z}^{l+1} =\text{MLP}\left(\text{LN}\left(\mathbf{y}^{l}\right)\right)+ \mathbf{y}^{l},\]  
where \(l=0,\ldots,L-1\). The MSA consists of \(k\) self-attentions operating in parallel, while the MLP block comprises two dense layers and the GELU activation function [34] between  
Figure 3: Tubelets extracted from sequence of input frames. Figure 2: Network architecture for ViViT, which consists of embedding layers, transformer encoders, and classifier. the layers, as developed in [30]. The number of nodes in the two dense layers of the MLP is set to \(d_{ff}\) and \(d\), respectively. Among the output tokens of the transformer encoders, \(z_{cls}^{L}\in\mathbb{R}^{d}\) is forwarded to the classifier, which predicts the label \(\hat{y}\in\mathbb{R}^{N_{C}}\) of the grid where gas detonation occurred. \(z_{cls}^{L}\) is the token created by passing the classification token \(z_{cls}\) through the encoder.