## 2 Methods
### Root Cause Tracing Based on Adam Variational Inference Bayesian Neural Network
#### 2.2.3 Root Cause Tracing Based on Adam Variational Inference Bayesian Neural Network
\begin{split}\frac{\partial\text{ELBO}}{\partial\mu}& =\frac{\partial}{\partial\mu}\Big{(}\int q(w)\log p(X,Z|w)dw-\int q (w)\log\frac{q(w)}{p(w)}dw\Big{)}\\ &=\frac{\partial}{\partial\mu}\Big{(}\int\frac{1}{\sqrt{2\pi \sigma^{2}}}\exp\big{(}-\frac{(w-\mu)^{2}}{2\sigma^{2}}\big{)}\log p(X,Z|w)dw- \big{(}\log\frac{\sigma_{p}}{\sigma}+\frac{\sigma^{2}+\mu^{2}}{2\sigma_{p}^{2 }}-\frac{1}{2}\big{)}\Big{)}\\ &=\int\frac{w-\mu}{\sigma^{2}}q(w)\log p(X,Z|w)dw-\frac{\mu}{ \sigma_{0}^{2}}\\ &=\frac{1}{\sigma^{2}}\mathbb{E}_{q(w)}[(w-\mu)\log p(X,Z|w)]- \frac{\mu}{\sigma_{0}^{2}}.\end{split}  \tag{29}\]  
\[ \begin{split}\frac{\partial\text{ELBO}}{\partial\sigma^{2}}& =\frac{\partial}{\partial\sigma^{2}}\Big{(}\int q(w)\log p(X,Z|w)dw -\int q(w)\log\frac{q(w)}{p(w)}dw\Big{)}\\ &=\frac{\partial}{\partial\sigma^{2}}\Big{(}\int\frac{1}{\sqrt{2 \pi\sigma^{2}}}\exp\big{(}-\frac{(w-\mu)^{2}}{2\sigma^{2}}\big{)}\log p(X,Z|w) dw-\big{(}\log\frac{\sigma_{0}}{\sigma}+\frac{\sigma^{2}+\mu^{2}}{2\sigma_{0}^{2}}- \frac{1}{2}\big{)}\Big{)}\\ &=\int\Big{(}\frac{(w-\mu)^{2}}{2\sigma^{4}}-\frac{1}{2\sigma^{2} }\Big{)}q(w)\log p(X,Z|w)dw-\Bigg{(}\frac{1}{2\sigma^{2}}-\frac{1}{2\sigma_{0} ^{2}}\Bigg{)}\\ &=\mathbb{E}_{q(w)}\bigg{[}\Big{(}\frac{(w-\mu)^{2}}{2\sigma^{4} }-\frac{1}{2\sigma^{2}}\Big{)}\log p(X,Z|w)\bigg{]}-\Bigg{(}\frac{1}{2\sigma^{ 2}}-\frac{1}{2\sigma_{0}^{2}}\Bigg{)}.\end{split}  \tag{30}\]  
The derivative results need to be approximated by Monte Carlo sampling to compute the expectation term in the ELBO. The specific steps are as follows: Randomly sample  
Figure 9: Diagram of causal variables. weights \(w\) from the approximate distribution \(q(w|\mu,\sigma^{2})\). Compute the gradients with respect to the sampled weights and use these gradients to update the distribution parameters \(\mu\) and \(\sigma\). In each gradient update step, use the Adam optimization formula to update the parameters \(\mu\) and \(\sigma\). The update rule for Adam [31] includes the following steps:  
Calculation of first-order momentum:  
\[m_{\mu,t} =\beta_{1}m_{\mu,t-1}+(1-\beta_{1})\
abla_{\mu}\text{ELBO}, \tag{31}\] \[m_{\sigma,t} =\beta_{1}m_{\sigma,t-1}+(1-\beta_{1})\
abla_{\sigma}\text{ELBO}. \tag{32}\]  
Calculation of second-order momentum:  
\[v_{\mu,t} =\beta_{2}v_{\mu,t-1}+(1-\beta_{2})(\
abla_{\mu}\text{ELBO})^{2}, \tag{33}\] \[v_{\sigma,t} =\beta_{2}v_{\sigma,t-1}+(1-\beta_{2})(\
abla_{\sigma}\text{ELBO })^{2}. \tag{34}\]  
Bias correction:  
\[\hat{m}_{\mu,t}=\frac{m_{\mu,t}}{1-\beta_{1}^{t}},\quad\hat{m}_{ \sigma,t}=\frac{m_{\sigma,t}}{1-\beta_{1}^{t}}, \tag{35}\] \[\hat{v}_{\mu,t}=\frac{v_{\mu,t}}{1-\beta_{2}^{t}},\quad\hat{v}_{ \sigma,t}=\frac{v_{\sigma,t}}{1-\beta_{2}^{t}}. \tag{36}\]  
Update distribution parameters:  
\[\mu_{t+1} =\mu_{t}-\frac{\eta}{\sqrt{\hat{v}_{\mu,t}}+\epsilon}\hat{m}_{\mu,t}, \tag{37}\] \[\sigma_{t+1} =\sigma_{t}-\frac{\eta}{\sqrt{\hat{v}_{\sigma,t}}+\epsilon}\hat{ m}_{\sigma,t}. \tag{38}\]  
In the Bayesian neural network, the Adam optimization algorithm can help the model converge faster. Due to its adaptive learning rate feature, it is particularly well-suited for handling different parameters in the network, which is especially important for parameter estimation in Bayesian methods. The adaptive nature of Adam ensures that the learning rates for different parameters are adjusted based on their individual gradients, thus optimizing the training process by improving both efficiency and stability. This makes it an ideal choice for optimizing the variational distributions in Bayesian neural networks, where parameter uncertainty plays a crucial role in the model's performance. The mathematical model of the above method can be expressed as  
\[y=f(x;w)+\epsilon \tag{39}\]  
where \(y\) represents the probability vector of abnormal occurrence of various factors, \(f(x;w)\) is a function defined by a neural network that depends on the input \(x\) and the network parameters \(w\), and \(\epsilon\) is the error of the model.