## 3 Methodology
### Data Enhancement Based on Diffusion Model
#### 3.2.3 Diffusion Model
The corresponding reverse process distributions are defined as:  
\[p_{\theta}(x_{t-1}|x_{t})=N\Big{(}x_{t-1};\mu_{\theta}(x_{t},t),\sigma_{t}^{2}I \Big{)} \tag{7}\]  
The variance \(\sigma_{t}^{2}\) is a time-dependent constant (\(\beta_{t}\)). The \(\mu_{\theta}(x_{t},t)\) is a neural network with an input \(x_{t}\). In order to share parameters between timesteps, the conditioning variable \(t\) is introduced in the form of positional embeddings [22]. The forward process samples \(x_{t}\) can be written as a function of \(x_{0}\) and some noise \(\epsilon\sim N(0,I)\). We assume \(p(x_{t-1}|x_{t})\) is a Gaussian distribution, and we can use a neural network to fit it. Combine the generated noise tags as training reference. The inverse process is also a Markov chain process. \[p_{\theta}(x_{0:T})=p(x_{T})\prod_{t=1}^{T}p_{\theta}(x_{t-1}|x_{t}) \tag{8}\]  
The corresponding process and results can be obtained as \(q(x_{t-1}|x_{t},x_{0})\)=\(\frac{q(x_{t}|x_{t-1},x_{0})q(x_{t-1}|x_{0})}{q(x_{t}|x_{0})}\). Set variance to constant \(\beta_{t}\), and continue to substitute the Gaussian probability density function for subsequent processing. Finally, it can be summarized as such:  
\[q(x_{t}|x_{t-1})=N\Big{(}x_{T};x_{t-1}\sqrt{1-\beta_{t}},\beta_{t}I\Big{)} \tag{1}\]0  
Then, calculate the likelihood function of the target data distribution, so that the network can be trained. The mean fitted is \(\mu_{\theta}(x_{t},t)=\frac{1}{\sqrt{\alpha}}(x_{t}-\frac{\beta_{t}}{1- \overline{\alpha_{t}}}\epsilon_{\theta}(x_{t},t))\), and this can be used for sampling. The subsequent sampling process samples \(x_{T}\) from the standard normal distribution and calculates \(x_{t-1}\) iteratively. Known mean \(\mu_{\theta}(x_{t},t)\) and constant variance \(\beta_{t}\), \(x_{t-1}\) to \(x_{0}\) can be calculated by parameter renormalization. This training objective also be viewed as a weighted combination of denoising score matching used for training score-based generative models [23]. In fact, the idea of the Denoising Diffusion Probabilistic Model (DDPM) is very simple. In reverse diffusion, \(X_{t}\) is used to predict \(X_{t-1}\) images. Instead of optimizing the \(X_{t}\) to \(X_{t-1}\) conversion, it is to optimize how noise is added when \(X_{t-1}\) to \(X_{t}\). At the same time, DDPM also adds time embedding [24]. In this model, we will use U-Net. U-Net is a U-shaped network structure, which is widely used in the segmentation field. The structure of this network is symmetrical, filled with convolutional layers but without fully connected layers. This method combines high-resolution feature maps with low-resolution feature maps after upsampling, which makes the segmentation results more accurate. At the same time, in the upsampling stage, the model still has a large number of channels, and more detailed object information will be transmitted back through upsampling. From the shape, the upsampling stage and the downsampling stage are symmetrical. The function of time embedding is to tell U-Net (used to generate random noise and other work) the position of reverse diffusion. Another reason for adding time embedding is that U-Net shares parameters. Adding time embedding can generate different outputs based on different inputs. Through these methods, U-Net can form some rough contours in the process of reverse diffusion. As it progresses close to the original image, we hope to obtain object edge information and some high-frequency information, so as to make the output image more realistic [25]. We utilize an attention mechanism to capture the temporal and feature dependencies of time series. To capture temporal and feature dependencies of multivariate time series, we utilize a two-dimensional attention mechanism in each residual layer instead of a convolution architecture [26]. The attention mechanism allows the model to handle various lengths. For batch training, we apply zero padding to each sequence so that the lengths of the sequences are the same. This is also the key model used in this study.