# Environmental Attention-Guided Branchy Neural Network for Speech Enhancement
## Appendix A  
In this Appendix, we present the details on the derivation of gradient propagation in the proposed denoising neural network, and its structure is shown in Figure 11. In the training stage, the MSE objective function is used as the optimization target, which is given by the sum of the mean square loss of each frequency bins in every mini batch:  
\[J_{MSE}=\frac{1}{N\cdot K}\sum_{t=1}^{N}\sum_{k=1}^{K}\left(\hat{Y}(k,t)-Y(k,t) \right)^{2} \tag{11}\]  
where \(J_{MSE}\) is the optimization target, and \(K\) and \(N\) denote the feature size of each output frame and the number of frames in each mini-batch, respectively. \(Y(k,t)\) is the ideal target for model learning and \(\hat{Y}(k,t)\) represents the estimated LPS feature from the forward propagation of the proposed denoising model. Equations (A2) to (A6) present the detailed forward propagation process:  
\[Z_{l-1}=W_{l-1}X+b_{l-1} \tag{12}\] \[A_{l-1}=g(Z_{l-1})\] (13) \[Z_{l,i}=p_{n_{i}}*(W_{l,i}A_{l-1}+b_{l,i})\] \[A_{l,i}=g(Z_{l,i}),i=1,2,\dots,m\] (14) \[Z_{l,m+1}=W_{l,m+1}A_{l-1}+b_{l,m+1}\] (15) \[A_{l,m+1}=g(Z_{l,m+1})\] (16) \[Z_{l+1}=\sum\limits_{i=1}^{m+1}(W_{l+1,i}A_{l,i}+b_{l+1,i})\] \[A_{l+1}=g(Z_{l+1})\] \[J_{MSE}=\frac{1}{N\cdot K}\sum_{t=1}^{N}\sum_{k=1}^{K}\left(\hat{Y}(k,t)-Y(k,t) \right)^{2} \tag{11}\]0  
where a middle hidden layer of the branchy model is indexed as \(l\), and subscript \(i\) denotes its branch index. \(X\) and \(\hat{Y}\) represent the concatenated noise-aware input features and enhanced LPS features, respectively. \(p_{n_{i}}\) is the estimated noise attention weight from the classification neural network. In the test stage, the extracted noise-aware features, \(X\), are fed to the branchy model to conduct the above forward propagation with applying attention weights, which will produce the enhanced LPS features \(\hat{Y}\) for speech reconstruction. After each forward propagation in one mini-batch, the gradients of MSE loss are calculated with chain rule and propagates from top to bottom layer by layer, as shown in Equations (A7) to (A12):  
\[ \begin{array}{ll}\mathrm{d}W_{l+2}&=\frac{\partial I_{MSE}}{\partial\hat{Y}} \frac{\partial\hat{Y}}{\partial W_{l+2}}\\ &=\frac{\pi}{N\mathcal{R}}\sum\limits_{l=1}^{K}\sum\limits_{k=1}^{K}(\hat{Y}( k,t)-Y(k,t))A_{l+1}\\ \mathrm{d}b_{l+2}&=\frac{\partial I_{MSE}}{\partial\hat{Y}}\frac{\partial\hat {Y}}{\partial W_{l+2}}\\ &=\frac{\pi}{N\mathcal{R}}\sum\limits_{l=1}^{N}\sum\limits_{k=1}^{K}(\hat{Y}( k,t)-Y(k,t))\end{array} \] (A7)  
According to Equation (A7), the gradients of the \((l+2)\)-th layer (output layer) are not affected by the attention weights, but the hidden layers below it will be affected by the factor \(p_{n_{i}}\) as follows:  
\[ \begin{array}{ll}\mathrm{d}W_{l+1,i}&=\frac{\partial I_{MSE}}{\partial\hat {Y}}\frac{\partial\hat{Y}}{\partial A_{l+1}}\frac{\partial A_{l+1}}{\partial \hat{Z}_{l+1}}\frac{\partial Z_{l+1}}{\partial W_{l+1}}\\ &=\frac{\pi}{N\mathcal{R}}\sum\limits_{l=1}^{K}\sum\limits_{k=1}^{K}(\hat{Y}( k,t)-Y(k,t))W_{l+2}*g^{\prime}(Z_{l+1})A_{l,i}\\ &=\sigma W_{l+2}*g^{\prime}(Z_{l+1})\xi[p_{n_{i}}*(W_{l,i}A_{l-1}+b_{l,i})],i= 1,2,\ldots,m\\ \mathrm{d}b_{l+1,i}&=\frac{\partial I_{MSE}}{\partial\hat{Y}}\frac{\partial \hat{Y}}{\partial A_{l+1}}\frac{\partial A_{l+1}}{\partial\hat{Z}_{l+1}} \frac{\partial Z_{l+1}}{\partial b_{l+1}}\\ &=\frac{2}{N\mathcal{R}}\sum\limits_{k=1}^{N}\sum\limits_{k=1}^{K}(\hat{Y}(k,t )-Y(k,t))W_{l+2}*g^{\prime}(Z_{l+1})\\ &=\sigma W_{l+2}*g^{\prime}(Z_{l+1})\end{array} \] (A8)  
\[