## 3 Proposed Method
### Variational Autoencoder  
In neural networks, VAEs are feedforward acyclic neural networks. They are an unsupervised machine learning method. They can effectively extract very good data features and reduce the dimension of high-dimensional data. As opposed to AE, VAE's latent space consists of a probability distribution of approximate data, while AE's consists of a specific encoding of the input data. Figure 2 shows a sample of a prior distribution in Euclidean space of VAE latent vectors. VAE's structure resembles classic autoencoders with encoders, decoders, and latent spaces. The network structure of VAE is shown in Figure 3.  
Figure 3: The VAE structure. Figure 2: Data density distribution in hidden space for normal and abnormal data. From Figure 3, \(p_{\theta}(z|x)\) is the inferred network model known as the encoder. The original input data \(X=\{x_{1},x_{2},...,x_{n}\}\) is mapped from the current space \(R_{n}\) to the hidden space \(R_{h}\) to obtain the variational probability distribution of the hidden layer \(z\). As input \(x\) and hidden space \(Z\) are connected, the inferred model learns the joint probability distribution between them. \(q_{\phi}(x|z)\) is the generative network model, that is, the decoder. It performs sampling from the probability distribution \(q_{\phi}(z|x)\) of the hidden layer \(Z\), and after sampling the hidden vector, \(z\) is decoded to produce an approximation of the target distribution \(\widehat{X}\). We applied the Bayesian formula as in Equation (1) to compute the probability distribution \(p_{\theta}(z|x)\) of the hidden variable \(Z\) given the data \(X\). \[p(z|x)=\frac{p(x|z)p(z)}{p(x)} \tag{1}\]  
We applied variational inference to approximate an unresolvable conditional probability distribution \(q_{\phi}(z|x)\) with a solvable distribution \(p_{\theta}(z|x)\) since the input data distribution \(p(x)\) is not computed as the dimensionality increases. We fitted the probability distributions \(p_{\theta}(z|x)\) and \(q_{\phi}(z|x)\), applying KL divergence to determine the disparity between them and to minimize the difference as best as possible. As shown in Equation (2),  
\[KL\big{(}q_{\phi}(z|x)||p_{\theta}(z|x)\big{)} =logp(x)+E\big{[}logq_{\phi}(z|x)\big{]}-E[logp_{\theta}(z|x)]\] \[=logp(x)+E\big{[}logq_{\phi}(z|x)\big{]}-E[logp_{\theta}(z,x)] \tag{2}\]  
The model parameters are trained by minimizing the difference between the two probability distributions. A smaller difference shows better parameters are obtained from training the VAE. Since \(X\) is certain, the first term in the equation \(logp(x)\) is a fixed value, so the training objective becomes to minimize the last two items \(E\big{[}logq_{\phi}(z|x)\big{]}-E[logp_{\theta}(z,x)]\) of the equation, which is denoted as \(L\). Then \(-L\) represents the lower bound of evidence \(p(x)\). Here, minimizing \(L\) gives the maximized lower bound of evidence (ELBO), as shown in Equation (3):  
\[Max\big{[}-L(\theta,\phi)\big{]}=E_{z\sim q_{\phi}(z|x)}[logp_{\theta}(x|z)] -KL\big{(}q_{\phi}(z|x)||p(z)\big{)} \tag{3}\]  
The first term of the equation is: \(E_{z\sim q_{\phi}(z|x)}[logp_{\theta}(x|z)]\), which indicates the continuous random samples of the probability distribution of the hidden space \(z\). The second term reveals that the latent vector \(z\) is continuously sampled to ascertain that the probability of reconstructing the sample \(x\) is maximized, so that the post-validation distribution \(p_{\theta}(z|x)\) and the prior distribution of \(q_{\phi}(z|x)\) are as close as possible. In order to construct the loss function of the model from this, we first consider the similarity between the input and the output and then make use of reconstruction loss to measure the difference between them. Secondly, due to the peculiarity of its coding layer, the variational autoencoder uses the latent loss to measure the \"fitness\" between the true probability distribution and the standard normal distribution.