## 3 Materials and Methods
### Proposed Method
#### 3.3.4 Sliding Loss Function  
The sliding loss function is an optimization objective proposed to address the limitations of traditional loss functions in handling dynamic characteristics of time-series or multimodal data. Traditional loss functions, such as the mean squared error (MSE), compute the error between model predictions and ground truth values globally. The formulation of the MSE loss function is given as  
\[\mathcal{L}_{\text{MSE}}=\frac{1}{n}\sum_{t=1}^{n}(\hat{y}_{t}-y_{t})^{2}, \tag{33}\]  
where \(\hat{y}_{t}\) denotes the predicted value, \(y_{t}\) represents the ground truth, and \(n\) is the total number of samples. While this global computation approach is straightforward, it fails to capture the local variations in data, especially in scenarios with significant dynamic changes or prominent local features. To address this, the sliding loss function incorporates the concept of sliding windows, computing losses within localized windows to better capture the dynamic variations in data. Specifically, let the predicted values be \(\hat{\mathbf{y}}=[\hat{y}_{1},\hat{y}_{2},\ldots,\hat{y}_{n}]\) and the ground truth values be \(\mathbf{y}=[y_{1},y_{2},\ldots,y_{n}]\). With a sliding window of size \(w\), the sliding loss function is defined as  
\[\mathcal{L}_{\text{sliding}}=\frac{1}{n-w+1}\sum_{i=1}^{n-w+1}\frac{1}{w}\sum _{t=i}^{i+w-1}(\hat{y}_{t}-y_{t})^{2}. \tag{34}\]  
Unlike traditional loss functions, the sliding loss function computes errors independently within each window and averages the losses across all windows. This design balances global optimization with sensitivity to local dynamics, improving the model's performance in complex scenarios. The integration of the sliding loss function with the sliding-window computation network highlights their complementarity. In the sliding-window computation network, input data are divided into multiple local windows, and features within each window are processed independently, enabling efficient extraction of local information. Correspondingly, the sliding loss function calculates losses for the predictions and ground truth values within the same windows, enhancing the model's ability to learn dynamic patterns within these localized regions. A critical aspect of this integration is the consistency of the window size \(w\) across the feature extraction and loss computation processes. Ensuring identical strides and sizes for the model's feature extraction windows and the loss function's sliding windows guarantees alignment in optimization objectives. The sliding loss function offers a significant advantage in its dynamic adjustment capability. Traditional global loss functions may overly prioritize global errors, neglecting critical local patterns in data with uneven distributions or strong dynamic characteristics. By introducing the perspective of localized windows, the sliding loss function localizes error computation, enabling the model to effectively learn prominent dynamic patterns. Furthermore, this loss function significantly enhances the model's ability to capture local features in both time-series data (e.g., stock price prediction) and spatial data (e.g., image feature extraction). Mathematically, the global error distribution of the sliding loss function can approximate the global optimization objective through the linear combination of local windows. This relationship is demonstrated as follows: let the global error be \(\mathcal{L}_{\text{global}}\) and the local error within a window be \(\mathcal{L}_{\text{local}}(i)\). Then,  
\[\mathcal{L}_{\text{global}}=\frac{1}{n}\sum_{t=1}^{n}(\hat{y}_{t}-y_{t})^{2} \approx\frac{1}{n-w+1}\sum_{i=1}^{n-w+1}\mathcal{L}_{\text{local}}(i), \tag{35}\]  
where  
\[\mathcal{L}_{\text{local}}(i)=\frac{1}{w}\sum_{t=i}^{i+w-1}(\hat{y}_{t}-y_{t}) ^{2}. \tag{36}\]  
This approximation indicates that the sliding loss function not only optimizes the global error but also explicitly constrains the local error, enhancing the model's stability and flexibility.