## 3 Results
### Mapping Using ML Approach
#### 3.5.1 FCNN Model Training  
The training and validation set consist of encoded magnetic heat maps, where the precise position of the coil's center is indicated by the matching theoretical magnetic heat maps. For training purposes, we utilized a diverse range of encoded images with varying numbers of sensors, along with different coil positions and various magnetic moments. This is carried out to prevent overfitting. We mostly utilize experimental heat maps in the test set, along with synthetic heat maps.  
* FCNN meta parameters: We implement our network in Python using PyTorch. The network architecture consists of an input layer with 2500 neurons, 2 hidden layers (the first has 750 neurons and the second has 500 neurons), and an output layer, which has 2500 neurons. The total number of trainable parameters in the network is 3,503,750. The Adam optimization method with a learning rate of \(\alpha=0.01\) was chosen. The training process involves a total of 2000 simulations. These simulations were restricted in a two-dimensional area of 50 mm \(\times\) 50 mm. In each simulation, the following parameters were randomly chosen according to a normal distribution: 1. The coordinates of the center of mass of the coil, \((X_{cm},Y_{cm})\); 2. The orientation of the coil in the x-y plane, \(\theta\); 3. The length of the coil, \(l\); 4. The current intensity, \(I\). The mean and the variance for each parameter are given in Table 1.  
The training process was conducted for a total of 200 epochs using NVIDIA A100, with cuda version 12.1.  
The process is shown in Figure 12. It took 25 min of CPU time, and testing the network with our measurements (the measurements are equal to 1 simulation in size) took 20 ms. The final step is to test the model with experimental data (the magnetic heat map on the left side of Figure 8).  
\begin{table}
\begin{tabular}{c c c} \hline
**Parameter** & **Mean** & **Standard Deviation** \\ \hline \(\vec{R}_{cm}\) (mm) & 35.355 & 10.202 \\ \hline \(\theta\) (radians) & \(\pi\) & 1.813 \\ \hline \(l\) (mm) & 20.0 & 2.886 \\ \hline \(I\) (mA) & 50.5 & 28.589 \\ \hline \end{tabular}
\end{table}
Table 1: Mean and standard deviation of the parameters based on their uniform distributions.  
* Loss function: For training the FCNN we decided to use a loss function that combines a global and a local estimation error. The purpose was optimizing the network convergence from the full heat map point of view but still emphasizing the most significant physical structure, namely, the coil's center of mass, which can be considered as an anchor point. The global part of the loss function is given by the Structural Similarity Index Measure (SSIM) [35]. Unlike traditional metrics such as mean squared error (MSE) or peak signal-to-noise ratio (PSNR), which primarily focus on pixel-wise differences, SSIM considers changes in structural information, luminance, and contrast. This often makes it more aligned with human visual perception. SSIM is a combination of luminance, contrast, and structure. We chose the SSIM components' adjustment parameters to be \(\alpha=\beta=\gamma=1\). The local term of the loss function, noted as \(LF_{net}\), is defined by \[LF_{net}=(\vec{\rho}_{pred}-\vec{\rho}_{theoretical})^{2}\] (6) where \(\vec{\rho}_{pred}\) is the center of mass of the coil predicted by the FCNN, and \(\vec{\rho}_{theoretical}\) is its theoretical, i.e., exact, position. We summarize this hybrid loss function in the following expression: \[Loss=\lambda_{1}(1-SSIM)+\lambda_{2}LF_{net}\] (7) where \(0\leq\lambda_{1}\), \(\lambda_{2}\leq 1\), and \(\lambda_{1}+\lambda_{2}=1\).