# Numerically Optimized Fourier Transform-Based Beamforming Accelerated by Neural Networks
## 5 Replacing Optimization Algorithms by Trained ANNs  
Although aperture phase distributions can be recovered successfully by applying the optimization method discussed above, the optimization process is computationally expensive and slow. Therefore, it is unsuitable for applications that require real-time beamforming. However, the computational complexity can be dramatically reduced if instead one uses an FFNN pretrained on the optimal phase distributions obtained for a large set of beam deflections. In this way, the complex beamforming problem can be solved rapidly, even on moderate hardware. The pretrained FFNN in this case realizes a set of  
Figure 10: The project pattern and the electric field pattern before optimization, and the electric field pattern after optimization in polar coordinates for single- and dual-beam scenarios. (**a**) Single-beam scenario in polar coordinates, _xz_-plane. (**b**) Single-beam scenario in polar coordinates, _yz_-plane. (**c**) Single-beam scenario in polar coordinates, _xy_-plane. (**d**) Dual-beam scenario in polar coordinates, _xy_-plane. (**e**) Dual-beam scenario in polar coordinates, _xz_-plane. (**f**) Dual-beam scenario in polar coordinates, _yz_-plane. nonlinear functions that relate the directions of the main beam (or several beams) to the required reflection phases on a PMS. When dealing with a PMS controlled by varactor diodes, another FFNN can be pretrained to deduce the varactor control voltages from the phase distribution produced by the first FFNN. The second FFNN may also perform additional functions, e.g., it may implement corrections to the control voltages that would take into account parasitic coupling between the PMS elements, etc. In light of what has been just discussed, in this work we propose and develop two use cases for such pretrained ANNs: (1) a beamforming neural network (BFNN) and (2) a control FFNN. In the first case, i.e., the BFNN case, the phases are computed directly by a pretrained FFNN by inputting the desired main beam(s) targets into the model. In the second case, i.e., the control FFNN case, a pretrained FFNN takes the output of the BFNN as its input and computes the required control voltages. Figure (a)a presents the proposed ANN configuration, in which the blocks inside a dashed blue rectangle represent the control FFNN. Note that we deliberately split the ANN configuration into two FFNNs trained separately, because this allows us to have a better control over the training process. Moreover, in this work, in order to reduce the number of necessary neurons in the control FFNN, we subdivide it into repeating equal sub-blocks (\(\text{atan2}(x,y)\) and CTRLNN) shown in the figure. Such subdivision is possible if the PMS cell control voltages are independent from each other. The function of each component can be separately verified. In our realization, the BFNN consists of one input layer, one hidden layer with 32 neurons, and one output layer. A graphical representation of such FFNN is depicted in Figure (b)b. The input layer of the BFNN has \(2\times L\) neurons to accept the parameters of the main beams for each possible radiation pattern realization. The output layer comprises \(2\times M\times N=60\) neurons, which output the values of \(\sin\Phi_{mn}\) and \(\cos\Phi_{mn}\). The reason why such an approach was taken is explained in Section 5.1. The input parameters of the BFNN represented by vector \(\vec{X}_{BFNN}=(\theta_{1},\varphi_{1},\ldots,\theta_{L},\varphi_{L})\) are the spherical angles that define the main beams' directions, and the output parameters denoted by \(\vec{Y}_{BFNN}=(\sin\Phi_{11},\cos\Phi_{11},\ldots,\sin\Phi_{MN},\cos\Phi_{ MN})\) correspond to the reconstructed reflection phase values for each PMS cell. These are the data to which we fit the first FFNN model. Each CTRLNN sub-blocks consists of one input neuron, one hidden layer with 20 neurons, and one output neuron.