# GAO-FCNN-Enabled Beamforming of the RIS-Assisted Intelligent Communication System
## 3 Gao-Fnn
### Fully-Connected Neural Network
\begin{array}{l}\mathbf{W}_{T}^{(l+1)}=\mathbf{W}_{T}^{(l)}-\eta\
abla \mathbf{w}_{T}^{(l)}\psi(\mathbf{t},\mathbf{\tilde{t}})\\ \mathbf{W}_{R}^{(l+1)}=\mathbf{W}_{R}^{(l)}-\eta\
abla\mathbf{w}_{R}^{(l)}\psi( \mathbf{t},\mathbf{\tilde{t}})\\ \mathbf{\Phi}^{(l+1)}=\mathbf{\Phi}^{(l)}-\eta\
abla\mathbf{\sigma}^{(l)}\psi( \mathbf{t},\mathbf{\tilde{t}})\\ e^{(l+1)}=e^{(l)}-\eta\
abla\mathbf{\sigma}^{(l)}\psi(\mathbf{t},\mathbf{ \tilde{t}})\end{array} \right., \tag{18}\]  
where \(\mathbf{W}_{T}^{(l)}\) is the weight vector of the \(l\)-th layer at the transmitter, \(\eta\) denotes the learning rate, \(\
abla\mathbf{w}_{T}^{(l)}\) is the gradient vector of the \(l\)-th layer at the transmitter of \(\mathbf{W}_{T}^{(l)}\), \(\mathbf{W}_{R}^{(l)}\) is the weight vector of the \(l\)-th layer at the receiver, \(\
abla\mathbf{w}_{R}^{(l)}\) is the gradient vector pertaining to the \(l\)-th layer of \(\mathbf{W}_{R}^{(l)}\), \(\mathbf{\Phi}^{(l)}\) represents the matrix of the \(l\)-th layer of reflection phases associated with the RIS, \(\
abla\mathbf{\sigma}^{(l)}\) is the gradient vector pertaining to the \(l\)-th layer of \(\mathbf{\Phi}^{(l)}\), \(e^{(l)}\) is the bias of the \(l\)-th layer, and \(\
abla e^{(l)}\) is the gradient vector pertaining to the \(l\)-th layer of \(e^{(l)}\). Then, according to Algorithm 1, the weight regularization loss is used to prevent the model overfitting as follows:  
\[\left\{ \begin{array}{l}\mathbf{R}_{T}^{(l)}=\lambda\sum\limits_{j}\left| \left|\mathbf{W}_{T}^{(l)}\right|\right|_{2}^{2}\\ \mathbf{R}_{R}^{(l)}=\lambda\sum\limits_{j}\left|\left|\mathbf{W}_{R}^{(l)} \right|\right|_{2}^{2}\end{array} \right., \tag{19}\]  
where \(\lambda\) is the regularization coefficient, and \(\left|\left|\mathbf{W}_{T}^{(l)}\right|\right|_{2}^{2}\) and \(\left|\left|\mathbf{W}_{R}^{(l)}\right|\right|_{2}^{2}\) are the computation results of the L2-norm function. ```
forward propagation Input:\(\mathbf{t}=\{t_{1},t_{2},\ldots,t_{k}\ldots,t_{k}\}\in\{0,1\}^{k}\) Initialize:\(l_{0}=X\) For every layer \(l\) from \(1\) to \(L\)do: \(\mathbf{q}^{(l)}=\mathbf{W}^{(l)}*t_{k}+e^{(l)}\) # Linear transformation \(\mathbf{\xi}^{(l)}=\mathrm{ReLU}(\mathbf{q}^{(l)})\) # Activation function Output:\(\mathbf{\xi}^{(l)}\) (activation values of the final output layer) # back propagation Input:\(\mathbf{\xi}^{(l)}\) (true labels), CE loss function \(\psi(\mathbf{t},\mathbf{\tilde{t}})\) Initialize:\(dl/d\mathbf{\xi}^{(l)}l\) means derivative of the normalized output vector \(l\)-th layer with respect to \(\mathbf{\xi}^{(l)}\) For each layer \(l\) from \(1\) to \(L\)do: If\(l\) is not the output layer: \(\mathbf{R}^{(l)}=\lambda\sum\limits_{j}\left|\left|\mathbf{W}^{(l)}\right| \right|_{2}^{2}\) Compute the weight regularization loss Else: \(\
abla^{(l)}=dl/d\mathbf{\xi}^{(l)}*\mathrm{ReLU}/\left(\mathbf{q}^{(l)} \right)\) # Compute gradient \(d\mathbf{W}^{(l)}=\
abla^{(l)}*(\mathbf{\xi}^{(l-1)})_{T}\) # Compute weight gradient \(de^{(l)}\) = np.sum(\(\
abla^{(l)}\), axis = 1, keep dims = True) # Compute bias gradient, axis = 1 sums across rows # Update weight values and biases \(\mathbf{W}^{(l)}=\mathbf{W}^{(l)}-\eta*d\mathbf{W}^{(l)}*\mathbf{\tilde{\tau}} (\mathbf{t},\mathbf{\tilde{t}})\) \(e^{(l)}=e^{(l)}-\eta*de^{(l)}*\psi(\mathbf{t},\mathbf{\tilde{t}})\) Output: Updated \(\mathbf{W}^{(l)}\) and \(e^{(l)}\) for all layers \(L\)
```  
**Algorithm 1**The essential process pertaining to the FCNN