# Kalman Filter-Based Differential Privacy Federated Learning Method
## 3 Proposed Method
### Method Details
#### 3.2.3 Details of Kalman Noise Reduction  
The Kalman filter is able to reduce the noise of normal distribution in the linear system [18]. The noise added to the training result after differential privacy is Gaussian noise satisfying the condition of normal distribution, and the state update equation is linear, so the Kalman filter can be used for noise reduction in the training result to decrease the impact of differential privacy on the accuracy of the model. The noise revising has two steps, the first step is the model parameters' update, and the second step is the parameters' update correction.  
There are \(C\) TNs in the \(t\)th round of federated learning; the model parameters of the TN\({}_{c}\) are \(w_{t,c}\), the global model parameters are \(w_{t}\), the parameter vector composed of the model parameters of all TNs is \(W_{t}=\begin{bmatrix}w_{t}&w_{t,1}&w_{t,2}&\cdots&w_{t,N}\end{bmatrix}\), and the gradient values of TN\({}_{c}\) are \(g_{t,c}\). Then, the gradient vector composed of the gradient values of all TNs is \(G^{\prime}_{t}=\begin{bmatrix}0&g^{\prime}_{t,1}&g^{\prime}_{t,2}&\cdots&g^{ \prime}_{t,c}\end{bmatrix}\). The linear coefficient matrix of the state prediction equation \(U\) is a unit matrix, and \(V\) is defined as following:  
\[V=\begin{bmatrix}1&0&0&\dots&0\\ 0&\frac{\lambda}{c}&0&\dots&0\\ 0&0&\frac{\lambda}{c}&\dots&0\\ \dots&\dots&\dots&\ddots&\dots\\ 0&0&0&\dots&\frac{\lambda}{c}\end{bmatrix} \tag{8}\]  
Then, the parameter update equation for model training can be transformed into the state prediction equation:  
\[W_{t+1}^{T}=UW_{t}^{T}+VG^{\prime T}_{t} \tag{9}\]  
In fact, the parameter update equation Equation (9) for model training can also be written as:  
\[\begin{cases}w_{t+1}=w_{t}-\lambda\sum_{c\in C}g^{\prime}_{t,c}\\ w_{t+1,1}=w_{t,1}-\lambda g_{t,1}+\mathcal{N}\left(0,\sigma^{2}M^{2}I\right)\\ \dots\\ w_{t+1,c}=wt,c-\lambda g_{t,c}+\mathcal{N}\left(0,\sigma^{2}M^{2}I\right)\end{cases}\, \tag{10}\]  
The noise added by the TN in differential privacy uses the Gaussian mechanism satisfying Gaussian distribution.  
To achieve dimensional matching with \(U\) and \(V\), we need the calculation described in Algorithm 3. The elements in \(W_{t}^{T}\) and \(G^{\prime T}_{t}\) are all matrix. First, we reshape each element in \(W_{t}^{T}\) and \(G^{\prime T}_{t}\). Let \(N=m\times n\), and each matrix \(w_{t,c}\) or \(g^{\prime}_{t,c}\) shaped \(m\times n\) will be reshaped to \(N\times 1\). Let \(\varpi_{c,i}\) be the \(i\)th parameter in \(w_{t,c}\) and \(\varpi_{c,i}\) be the \(i\)th in \(g^{\prime}_{t,c}\). Then, we can calculate Equation (9) using Algorithm 3.  
The gradient vector \(G_{k}^{{}^{\prime}T}\) contains noise added by the TN, and the distribution of the noise is known. The Gaussian noise added by the differential privacy is considered an external disturbance, i.e., uncertainty in the system.  
In Kalman filtering, \(z_{t}\) is used to denote the actually obtained data, calculated using the following equation:  
\[z_{t}=HW_{t}+R, \tag{11}\]  
where \(H\) is the data unit transformation matrix. In this paper, the data sent by the TN are the same as the data obtained by the RN; so, \(H\) is the \(C+1\) dimensional unit vector. \(R\) is the error column vector. In order to avoid the occurrence of a singular matrix in subsequent calculations, here, \(R=0.1Q\) is taken. The calculation of the Kalman gain matrix using the noise covariance matrix \(P_{t}\) is  
\[K_{t+1}=HP_{t}H^{T}\Big{(}HP_{t}H^{T}+R\Big{)}^{-1} \tag{12}\]  
Since \(H\) is a \(C+1\) dimensional unit vector, the formula for the Kalman gain can be reduced to  
\[K_{t+1}=P_{t}(P_{t}+R)^{-1}. \tag{13}\]  
The parameter update equation using the Kalman gain correction is  
\[W_{t+1}=W_{t}+K_{t}(z_{t}-HW_{t}). \tag{14}\]  
We update the covariance matrix of the norm noise:  
\[P_{t+1}=(I-K_{t}H)P_{t}+Q. \tag{15}\]  
\[Q\sim\mathcal{N}\Big{(}0,\sigma^{2}M^{2}I\Big{)} \tag{16}\]