In this paper, we develop a deep learning approach for the accurate solution of challenging problems of near-field microscopy that leverages the powerful framework of physics-informed neural networks (PINNs) for the inversion of the complex optical parameters of nanostructured environments. Specifically, we show that PINNs can be flexibly designed based on full-vector Maxwell’s equations to inversely retrieve the spatial distributions of the complex electric permittivity and magnetic permeability of unknown scattering objects in the resonance regime from near-field data. Moreover, we demonstrate that PINNs achieve excellent convergence to the true material parameters under both plane wave and point source (localized) excitations, enabling parameter retrieval in scanning near-field optical microscopy. Our method is computationally efficient compared to traditional data-driven deep learning approaches as it requires only a single dataset for training. Furthermore, we develop and successfully demonstrate adaptive PINNs with trainable loss weights that largely improve the accuracy of the inverse reconstruction for high-index materials compared to standard PINNs. Finally, we demonstrate the full potential of our approach by retrieving the space-dependent permittivity of a three-dimensional unknown object from near-field data. The presented framework paves the way to the development of a computationally driven, accurate, and non-invasive platform for the simultaneous retrieval of the electric and magnetic parameters of resonant nanostructures from measured optical images, with applications to biomedical imaging, optical remote sensing, and characterization of metamaterial devices.

## I. INTRODUCTION

In the past few decades, the engineering of electromagnetic waves in optical materials heavily relied on either analytical theories or numerical methods to obtain the solutions of physics-based partial differential equation (PDE) models. However, it has become increasingly difficult to apply these traditional approaches to complex optical structures and heterogeneous media, particularly in relation to the challenging inverse problems of near-field optical microscopy with many applications to biomedical imaging, material characterization, and nano-optical device inspection.^{1–4} Specifically, the parameter retrieval problem of near-field microscopy consists in estimating the properties of a scattering object, usually identified by its shape and dielectric permittivity, from a limited set of near-field data under different excitation conditions. Thanks to the impressive developments of the scanning near-field optical microscopy (SNOM) technique,^{5} it is currently possible to image the amplitude and phase of the scattered fields of complex nanostructures in the near-field zone with nanoscale spatial accuracy.^{2–10} In particular, by exciting and detecting photonic structures locally, near-field techniques provide a “non-invasive” approach for the characterization of complex nanostructures. However, due to the strong multiple scattering of radiation in multi-particle systems at large refractive index contrast,^{11} the problem of retrieving the material optical constants from near-field data becomes intrinsically non-linear and ill-posed. As a result, iterative optimization methods are proposed to solve these inverse problems with good accuracy, but they are usually computationally expensive.^{12–18} On the other hand, there is a growing interest in developing deep learning (DL) algorithms for electromagnetic wave engineering. This rapidly emerging approach includes training artificial neural networks (ANNs) to solve the photonics inverse problems.^{19–29} Although demonstrated successfully at solving several inverse problems,^{23,24} DL methods are essentially data-driven techniques that require a time-consuming training process in order to instruct ANNs using massive datasets. In order to improve on purely data-driven DL methods, it is important to constrain them by leveraging the underlying physics of the problems, thus relaxing the burden on the training and data acquisition steps. Therefore, it is critical to build a robust framework that efficiently integrates powerful ANN architectures with the physical laws that fundamentally constrain the complex parameter retrieval problems of near-field microscopy. In this context, the physics-informed neural network (PINN) is a general framework developed for solving both forward and inverse problems that are mathematically modeled by arbitrary PDEs of integer or fractional orders.^{30–32} In our previous work, we have applied PINNs to retrieve purely real permittivities of lossless materials from real-valued electric field observations under plane wave excitation.^{33}

In this paper, we develop a more general PINN framework for solving the parameter retrieval problems of near-field optical microscopy that are of direct interest to biomedical imaging and nanotechnology. In particular, we address and demonstrate the accurate retrieval of the complex electric permittivity *ɛ*_{r} of resonant nanostructures based on complex wave equations using complex electric field (synthetic) data obtained from forward finite element method (FEM) simulations. Furthermore, we demonstrate the retrieval of the complex magnetic permeability *μ*_{r} of resonant nanostructures based on the full inversion of Maxwell’s equations. We show that PINNs retrieve correctly the material parameters from near-field data sampled under both plane wave and localized (line current source) excitations, which can enable inverse parameter retrieval using the dual-SNOM technique.^{2,8,10} Importantly, we show the simultaneous inverse retrieval of the space-dependent material parameters *ɛ*_{r} and *μ*_{r} without prior shape information in a two-dimensional (2D) geometry. In this context, an adaptive PINN algorithm is proposed and developed to improve the stability and accuracy in retrieving high-index material parameters in a regime where the standard PINN method fails. Finally, we demonstrate the full potential of our method by successfully retrieving the complex permittivity profile of an unknown three-dimensional (3D) scattering object from sampled synthetic data. We remark that the framework shown here is more general than the one shown in our previous work^{33} and can be used to simultaneously retrieve the space-dependent complex optical parameters of unknown objects with electric and magnetic resonant responses in the presence of losses and under different excitation conditions. Here, we demonstrate our approach by retrieving the optical constants for linear and isotropic materials. However, the developed framework can be naturally extended to retrieve nonlinear optical and anisotropic parameters by implementing more general wave equations.^{34} All the implementations of the developed PINN algorithms used in this paper are obtained within the powerful DeepXDE library.^{31}

The general PINN algorithm utilized for solving inverse PDE problems is schematically illustrated in Fig. 1. We first construct an artificial neural network (ANN) with input vector **x** = (*x*_{1}, *y*_{1}; *x*_{2}, *y*_{2}; …; *x*_{N}, *y*_{N}) whose coordinates denote either points on a grid or randomly distributed points over the investigated domain Ω and output $u\u0302(x;\theta ,\xi )$ that is a surrogate of the PDE solution *u*(**x**).^{31} Here, ** θ** denotes a vector containing all the weights and biases in the ANN and

*ξ*describes the unknown parameters in the PDEs that need to be retrieved. A simple fully connected neural network (FCNN) is employed here, but the method can conveniently be extended to accommodate more complex ANN architectures. Crucially, we have built the loss function that constrains $u\u0302$ to satisfy the PDEs describing the electromagnetic physics of the considered problems.

As a first example, we consider the near-field microscopy parameter retrieval problem of retrieving the complex relative permittivity *ɛ*_{r} defined on a domain Ω ⊂ **R**^{2} with the constraint as follows:

with boundary conditions $B(u,x)=0$ on *∂*Ω, where *ɛ*_{r} corresponds to the *ξ* parameter in PINNs and the function *f* is derived from wave equation as it will be discussed in Sec. II A 1. The derivatives of $u\u0302(x;\theta ,\epsilon r)$ in Eq. (1) are obtained using the auto differentiation of the ANN, which is already implemented in the TensorFlow package.^{35} We define the loss function that constraints our PINN formulations by

where *w*_{f}, *w*_{b}, and *w*_{i} are the loss weights and

where $Lf$, $Li$, and $Lb$ denote the *L*^{2} norm of residuals for the PDEs, complex field observations, and BCs, respectively. The symbols Re{·} and Im{·} denote the real and imaginary parts of a complex quantity, respectively. We can obtain the complex field observations *u*_{obs}(**x**) from experimental or numerical simulations (i.e., synthetic data). The quantities $Tf$, $Ti$, and $Tb$ denote the residual points for $Lf$, $Li$, and $Lb$, respectively.^{31} In the last step, we train the neural networks of PINNs to search for the parameters ** θ** and

*ɛ*

_{r}that minimize the total loss function specified in Eq. (2). As we will show in Sec. II, the proposed framework solves the parameter retrieval problem of near-field microscopy using only one set of complex field observations. We remark that using PINNs, we can solve a complex inverse problem by adding a small computational cost compared to the solution of the associated forward one

^{30,31,36}since the only difference between the two is the introduction of the extra loss term $Li$.

## II. RESULTS AND DISCUSSION

### A. Objects with known shapes

#### 1. Retrieval of the complex electric permittivity

We recently utilized the powerful PINN method for solving the inverse Mie scattering problem limited to lossless materials.^{33} Here, we extend the approach by taking into account the losses of the materials, which require the more difficult inversion of complex optical parameters. We start by considering the case of retrieving the complex permittivity of a single dielectric cylinder with a diameter comparable with the wavelength of light. Specifically, we study a cylinder with radius *r* = 2 *µ*m and *ɛ*_{r} = 3 + *j*(1) under TM polarized plane wave excitation at wavelength *λ* = 3 *µ*m. We obtain synthetic data by performing forward simulations using the FEM modeling^{33} (see Sec. IV for additional details on the FEM simulations). The *ɛ*_{r} real part profile of the simulated structure is shown in Fig. 2(a). We denote the region of vacuum (Re{*ɛ*_{r}} = 1) as Ω_{1} and the region occupied by the cylinder (Re{*ɛ*_{r}} = 3) as Ω_{2}.

Dynamic Maxwell’s equations allow one to derive the wave equation for a non-homogeneous medium in the following form:^{37}

where **E** is the electric field, **H** is the magnetic field, and *ɛ*(**r**) = *ɛ*_{0}*ɛ*_{r}(**r**) and *μ*(**r**) = *μ*_{0}*μ*_{r}(**r**) are the space-dependent medium permittivity and permeability, respectively. The symbols *μ*_{0} and *ɛ*_{0} denote the permeability and permittivity of free space, respectively. Without loss of generality, we first study the parameter retrieval in 2D geometries for retrieving the complex parameter *ɛ*_{r} under the TM polarization excitation **E**(**r**) = *E*_{z}(*x*, *y*), which yields **E** · ∇ln *ɛ*(*x*, *y*) = 0. In addition, we assume, at first, that a non-magnetic object with relative permeability *μ*_{r}(**r**) = 1 for which ∇ln *μ* = 0 yields the following wave equation:

Separating the real and imaginary parts of the wave equation, we obtain the following PDE model that we have implemented in our PINNs:

where $k0=2\pi \lambda $ is the incident wave number. Since the shape of the object is known *a priori*, we denote by *ɛ*_{r1} and *ɛ*_{r2} the complex homogeneous permittivity in regions Ω_{1} and Ω_{2}, respectively, and we impose the electromagnetic BCs at the boundary *∂*Ω as follows:

where $Ez(k),(k=1,2)$ are the complex electric fields in domain Ω_{k} and *r* is the radial component in polar coordinates with its origin at the center of the cylinder. The real and imaginary parts of *E*_{z} obtained from FEM simulations and utilized for training PINNs are displayed in Figs. 2(b) and 2(c), respectively. We sample the complex *E*_{z} on a square grid in the Ω_{1} region with resolution Δ*x* = 0.02*λ* as the training dataset, which is achievable using current near-field microscopy techniques.^{22,23} We have also investigated the robustness of the retrieval with respect to different values of the spatial resolution Δ*x* in Sec. 2.3 of the supplementary material. We set the initial value *ɛ*_{r2} = 1 + *j*(−1) and train the FCNN by minimizing the loss function specified in Eq. (2). Further details on the training methods and the utilized hyperparameters of the FCNN are described in Sec. IV. The retrieved values of the complex permittivity *ɛ*_{r2} with respect to the iteration number are shown in Fig. 2(d) where the values of the true solution are indicated by the dashed lines. The results displayed in Fig. 2 demonstrate the accurate retrieval of the complex permittivity of non-ideal lossy dielectric materials using PINNs. We show that PINNs can still accurately retrieve permittivity data starting from different initial values, as discussed in Sec. 2.2 of the supplementary material. Moreover, the developed PINN model successfully reconstructed the complex *E*_{z} distribution within Ω_{2} after training, as we show in Figs. 2(e) and 2(f) for the real and imaginary parts of *E*_{z}, respectively. The *L*^{2} errors of *E*_{z} between data obtained from FEM simulations and the predictions of PINNs are $\u223c10\u22124$ (the *L*^{2} error definition and its exact value for *E*_{z} real and imaginary parts are discussed in Sec. 2.7 of the supplementary material). Therefore, we conclude that PINNs can be reliably extended to obtain the electric permittivity of resonant nanostructures from complex electric field data. In Sec. II A 2, we introduce an even more general PINN model for the simultaneous retrieval of the complex optical parameters of electric and magnetic scattering media.

#### 2. Retrieval of permittivity and permeability

In this section, we consider the retrieval of both the *μ*_{r} and *ɛ*_{r} values of magnetic materials that have important applications in biomedical, environment treatment, and nanotechnology.^{38–41} Since the parameters *μ*_{r} and *ɛ*_{r} are coupled in Eq. (7), we now consider a PDE model based on dynamic Maxwell’s equations, where *μ*_{r} and *ɛ*_{r} appear separately. In particular, for the TM polarization, the PDEs are as follows:

We denote the relative permeability and permittivity of region Ω_{k} as *μ*_{rk} and *ɛ*_{rk} (*k* = 1, 2), respectively. Here, *H*_{x} and *H*_{y} represent the *x* and *y* components of the magnetic field, respectively. We simulate a cylinder with the same geometry as shown in Fig. 2(a), and we set *ɛ*_{r1} = *μ*_{r1} = 1, *ɛ*_{r2} = 1, and *μ*_{r2} = 2.5 + *j*(0.6). The same notations of Ω_{1} for the vacuum region and Ω_{2} for the cylinder region are used. We can directly apply the following BCs at the cylinder boundary Ω_{2} to constrain the PINN’s retrieval of the optical constants using

where $n\u20d7$ is the unit vector normal to *∂*Ω and $Hk=(Hx(k),Hy(k)),(k=1,2)$ is the magnetic field vector in the region Ω_{k}.

We perform the FEM simulations with details specified in Sec. IV and obtain the complex *E*_{z}, *H*_{x}, and *H*_{y} field data for training the network. Similar to the approach of retrieving *ɛ*_{r}, we sampled these fields only in the region Ω_{2} considered as the training dataset. We train the FCNN (see Sec. IV for more details) to retrieve the complex *μ*_{r2} by fixing *ɛ*_{r1} = *μ*_{r1} = 1 and *ɛ*_{r2} = 1. *μ*_{r2} starts from the initial value *μ*_{r2} = 2. The reconstructed complex *E*_{z} profile obtained from the PINNs is shown in Sec. 1.1 of the supplementary material. We display the reconstructed complex *H*_{x} and *H*_{y} field profiles in Figs. 3(a) and 3(b) and Figs. 3(c) and 3(d), respectively. We show the parameter retrieval during the training process in Fig. 3(e), where very good convergence to the complex *μ*_{r2} true solutions (indicated by the dashed lines) is obtained. Moreover, we demonstrate that the retrieval results also converge to the true solutions for different initial values in Sec. 2.2 of the supplementary material. We quantify the convergence by computing the maximum *L*^{2} error norm between the reconstructed fields from PINNs and FEM simulations, which we found to be 8 × 10^{−3} (detailed values are reported in Sec. 2.7 of the supplementary material). The scaling of the total loss with respect to the iteration numbers is displayed in Fig. 3(f) where a satisfactory loss of ≈10^{−2} is reached. Moreover, in Sec. 2.4 of our supplementary material, we show that PINNs can retrieve simultaneously *μ*_{r} and *ɛ*_{r} for a cylinder with a training dataset sampled over both Ω_{1} and Ω_{2}. Therefore, we have shown that the proposed framework can be generally implemented to solve the near-field parameter retrieval problem for both the electric and magnetic properties of an object of a given shape based on Maxwell’s equations under plane wave excitation. In Sec. II A 3, we consider how to solve such a problem under a local source excitation, which is directly relevant to the applications of the SNOM technique for inverse parameter retrieval.

#### 3. Permittivity retrieval using the dual-SNOM setup

In Sec. II A 2, we discuss the parameter retrieval of complex *ɛ*_{r} and *μ*_{r} from the near-field data under plane wave excitation. However, in many applications of the SNOM technique, complex nanostructures are often illuminated using an excitation probe in the near-field.^{2–10} In particular, we address here the parameter retrieval problem of the dual-SNOM technique^{2,8,10} that uses two localized probes for the simultaneous excitation and detection of the investigated nanostructures. The FEM setup for simulating the parameter retrieval using the dual-SNOM is schematically illustrated in Fig. 4(a). We illuminate the same photonic structure as in Sec. II A 1 with a line current source along the z-axis (out-of-plane) at the position indicated by the small red dot that emulates the excitation probe. The near-field information for training PINNs is then collected by the detecting probe that is scanned across the detection area (white dashed square, excluding the cylinder domain). We keep the same field sampling resolution as in the previous examples. The wave equation models in Eqs. (8) and (9) can still be implemented because the electric field is still TM polarized **E**(**r**) = *E*_{z}(*x*, *y*). Furthermore, the BCs described by Eqs. (10)–(13) can also be applied. We train an FCNN with the same hyperparameters and training method used in Sec. II A 1. The obtained complex electric field *E*_{z} profiles from the PINN are shown in Figs. 4(b) and 4(c), where we retrieve the *E*_{z} profiles also inside the cylinder region (based uniquely on external field data). We evaluate the *L*^{2} errors for the *E*_{z} complex field between the FEM simulation and PINNs to be $\u223c1\xd710\u22124$ (detailed values are given in Sec. 2.7 of the supplementary material). The complex *ɛ*_{r} retrieval with respect to the number of iterations is shown in Fig. 4(d), demonstrating the rapid convergence to the true values using the dual-SNOM configuration. The PINNs based on the wave equation can hence successfully retrieve *ɛ*_{r} using only the external near-field data under different excitation conditions. Furthermore, the simultaneous retrieval of *ɛ*_{r} and *μ*_{r} for photonic structures can also be achieved following the same approach. Therefore, the PINN framework can be directly applied to solve the electric and magnetic material parameter retrieval problems under the dual-SNOM setup.

#### 4. Parameter retrieval in the presence of noise

In this section, we study the robustness of the parameter retrieval problem in the presence of noise. Although we assumed the accurate near-field measurement (synthetic field data from FEM simulations) in Secs. II A 1–II A 3, real experimental data acquisitions are subjected to uncertainties and errors in any practical measurement systems. It has been recently shown that PINNs can effectively de-noise the noisy data and obtain convergence to the ground truth for realistic magnetic resonance images^{36} and surface acoustic data.^{42} Furthermore, the Gaussian process smoothed PINNs are shown to recover the performance of the PINN for solving the Schrödinger equation with noisy and corrupted initial data.^{43}

Here, we show that PINNs are robust to the presence of noise in the near-field measurements for the parameter retrieval problem of electromagnetic scattering systems. We consider the presence of additive Gaussian noise in the complex *E*_{z} external field data used for the complex *ɛ*_{r} retrieval. Specifically, we superimpose the zero-mean Gaussian noise with standard variation *σ* = 0.05 (10% of the maximum *E*_{z} amplitude) to the real and imaginary parts of the complex training dataset used in Sec. II A 3. The real part of the obtained complex training dataset is shown in Fig. 5(a), and its imaginary part is displayed in Fig. 5(b). We use the same neural network as implemented for Fig. 4, while we train it using the noisy training dataset. We show the parameter retrieval process with respect to the iteration number in Fig. 5(c), where we demonstrate that the complex *ɛ*_{r2} still converges to the ground truth. Moreover, the PINN removed the noise in the complex *E*_{z} data in its reconstructed fields as shown in Figs. 5(d) and 5(e). We further evaluate the *L*^{2} errors between *E*_{z} reconstructed from PINNs and the one without noise and find these values to be 0.28% and 0.23% for the real and imaginary parts, respectively. However, we obtain a total loss value of 0.5 after 1 × 10^{4} iterations, which is larger than the one without noise. This is because we used a noisy dataset for training the PINN and reconstructed the *E*_{z} profiles without the noise. Therefore, the computed loss term $Li$ is expected to increase. Figure 5(f) shows how the relative error between the retrieved complex *ɛ*_{r2} value and its true value varies with respect to *σ* of the Gaussian noise. We can observe that the relative error for PINNs’ retrieval increases significantly with *σ*. Remarkably, we show that the PINN is capable of retrieving the optical parameters with relative error below 10% from noisy data with *σ* equal to 40% of the maximum *E*_{z} amplitude, yielding physically consistent reconstructions. In Sec. II B, we address the PINN approach to the complex parameter retrieval of resonant dielectric objects of unknown shapes.

### B. Objects with unknown shapes

#### 1. Retrieval of the complex permittivity profile

In this section, we address the challenging problem of retrieving not only the complex permittivity values in the resonant regime but also the unknown shapes of the scattering objects. In particular, we will show that the proposed PINN framework can be developed to retrieve the complex *ɛ*_{r}(*x*, *y*) profiles of unknown objects with dimensions comparable to or larger than the wavelength of the incident light by inverting the wave equations without imposing any BCs. The efficient solution of the inverse scattering problems in non-homogeneous media shown here simultaneously addresses both the parameter retrieval and the imaging problem of microscopy that are computationally prohibitive using the traditional retrieval methods.^{44,45} In order to demonstrate this capability using PINNs, we consider as a representative example the permittivity profile corresponding to the dimer configuration shown in Fig. 6(a). We set the larger cylinder with radius *r*_{1} = 2 *µ*m and permittivity *ɛ*_{r1} = 3 + *j*(1) centered at (*x*_{c1}, *y*_{c1}) = (0, 1 *µ*m) and the smaller cylinder with radius *r*_{2} = 0.8 *µ*m and permittivity *ɛ*_{r2} = 6 + *j*(2) centered at (*x*_{c2}, *y*_{c2}) = (0, −2 *µ*m). The complex field data *E*_{z} obtained from FEM simulation under TM plane wave excitation with *λ* = 3 *µ*m are shown in Figs. 6(b) and 6(c) for the real and imaginary parts, respectively. More details on the FEM simulations are provided in Sec. IV.

We implement the PDE model described by Eqs. (8) and (9) with a space-dependent complex relative permittivity $\epsilon rx,y$ over the entire square domain Ω. Since the shape of the object is not known *a priori*, no BCs can be implemented in this case and the problem directly deals with the inversion of a non-homogeneous extended medium. We then train PINNs with only the PDE and field observation constraints and retrieve the complex $\epsilon rx,y$ profile after the training process. Here, the complex $\epsilon rx,y$ functions are directly the outputs of the ANN rather than trainable variables as we used in the previous examples. To retrieve $\epsilon rx,y$ shown in Fig. 6(a), we employ the same FCNN architecture as in the last example and train it using the Adam optimizer for 1.5 × 10^{4} iterations until the total loss drops below 10^{−2}. The real and imaginary parts of the retrieved *ɛ*_{r} profile after training are shown in Figs. 6(d) and 6(e), respectively. We observe that the proposed framework retrieved successfully the shape information of the dimer setup in Fig. 6(d). Furthermore, we characterize the accuracy of the retrieved profiles by evaluating the complex *ɛ*_{r} inside each cylinder domain, and we obtain *ɛ*_{r1} = (2.92 ± 0.27) + *j*(0.96 ± 0.12) and *ɛ*_{r2} = (5.97 ± 0.34) + *j*(2 ± 0.15), which are in very good agreement with the input data. The *ɛ*_{r} errors estimated here are the standard deviations of the corresponding quantities within each cylinder domain. We also evaluate the *L*^{2} error between *E*_{z} obtained from PINNs and from the FEM simulations, which is $\u223c10\xd710\u22124$ (see Sec. 2.7 of the supplementary material for further details). We display the total loss with respect to the iteration in Fig. 6(f). The rapid spikes displayed by the total loss curve during the training process visibly demonstrate the highly non-linear nature of the parameter retrieval problem for near-field microscopy. Notice that we successfully retrieved the space profile of the complex permittivity *ɛ*_{r} at almost no additional computational cost compared to the previous example shown in Sec. II A 1, except that here we used the complex *E*_{z} data over the entire Ω domain as our dataset.

We further demonstrate the capability of retrieving shape information for more complex geometries and near-field data. We choose a non-canonical polygon geometry as shown in Fig. 7 with a high aspect ratio of 2.6 (the ratio between two different side lengths) and sharp edges. This polygon shape represents a generally complex geometry with the training datasets containing sharp field variations compared to the dimer geometry. We set the permittivity of the polygon equal to *ɛ*_{r} = 6 + *j*(3). The complex *ɛ*_{r} profile of the polygon real and imaginary parts is shown in Figs. 7(a) and 7(b), respectively. We use the same training setup as implemented for Fig. 6. The real and imaginary parts of *E*_{z} used for training are shown in Figs. 7(c) and 7(f), respectively. The PINN correctly retrieves the real part of *ɛ*_{r} as shown in Fig. 7(d) and the imaginary part as displayed in Fig. 7(e). We further characterize *ɛ*_{r} inside the polygon region and obtain *ɛ*_{r} = (5.8 ± 0.6) + *j*(2.8 ± 0.3), which is in agreement with the ground truth. For better visualization of the retrieval results, we further apply a threshold constraint to the obtained complex permittivity profiles. The results are displayed in Sec. 2.5 of the supplementary material. Therefore, the developed PINN inversion models demonstrate the accurate and efficient retrieval of both the complex permittivity values and the space distributions (i.e., shape information) of scattering objects. This achievement naturally augments near-field microscopy techniques by providing a robust, computationally driven platform for solving the imaging and the parameter retrieval problem of dielectric structures simultaneously.

#### 2. Simultaneous retrieval of permittivity and permeability profiles

In this section, we demonstrate how to improve the previous PINN setup in order to retrieve simultaneously both the *ɛ*_{r}(*x*, *y*) and *μ*_{r}(*x*, *y*) spatial profiles, providing both electric and magnetic optical parameters together with shape information for applications to inverse near-field microscopy. In this case, we must implement Eqs. (14)–(16) and retrieve the space-dependent functions $\epsilon rx,y$ and $\mu rx,y$ defined over the entire domain Ω. Since we are dealing with a full-domain, non-homogeneous retrieval problem, no BCs need to be applied here.

The investigated dimer has the same dimensions as previously shown in Fig. 6(a) except that here we set the optical constants of the two cylinders as *ɛ*_{r1} = 1, *μ*_{r1} = 1.5 + *j*(0.5) and *ɛ*_{r2} = 6 + *j*(3), *μ*_{r2} = 1, where one is purely magnetic, while the other one is purely dielectric. We run the FEM simulations with settings detailed in Sec. IV. The FEM simulation results for the real and imaginary components of *H*_{x} used for training PINNs are shown in Figs. 8(a) and 8(b), respectively. We display the training datasets *H*_{y} of real and imaginary parts in Figs. 8(c) and 8(d), respectively. The complex *E*_{z} field data used for training are shown in Sec. 1.2 of the supplementary material. The FCNN parameters and training details are given in Sec. IV. We trained the FCNN for 1.5 × 10^{4} iterations before reaching a satisfactory total loss value of 1.5 × 10^{−2}. The real part of permittivity and permeability spatial profiles retrieved by PINNs is shown in Figs. 8(e) and 8(f), respectively, which demonstrate the accurate reconstruct of each cylinder’s shape. We show the retrieved permittivity and permeability imaginary parts in Sec. 2.1 of the supplementary material. The obtained complex *ɛ*_{r}(*x*, *y*) and *μ*_{r}(*x*, *y*) profiles inside the two cylinder domains have constant values equal to *ɛ*_{r1} = (1.00 ± 0.19) + *j*(0 ± 0.01), *μ*_{r1} = (1.48 ± 0.07) + *j*(0.48 ± 0.07) and *ɛ*_{r2} = (5.75 ± 0.61) + *j*(3 ± 0.36), *μ*_{r2} = (1 ± 0.04) + *j*(0 ± 0.05), respectively. The maximum *L*^{2} error between fields from PINN and FEM simulations is evaluated to be 8 × 10^{−3}. Therefore, we successfully demonstrated the full retrieval of both the shape of the particle and values of the electric and magnetic parameters from synthetic electric and magnetic field data. However, in order to obtain stable results with better accuracy at large refractive index contrasts, we need to further generalize the PINN framework by introducing adaptive weights, as discussed in Sec. II C.

### C. Adaptive PINNs: Improved accuracy for high-index materials

In Secs. II A and B, we showed that PINNs are suitable for the retrieval of the complex *ɛ*_{r} and *μ*_{r} of resonant nanostructures from near-field observations outside the objects. However, the solutions of such complex inverse problems become progressively more inaccurate by increasing the refractive index contrast. For instance, we have shown in Sec. 2.6 of the supplementary material that the standard PINN approach loses its accuracy when increasing the *ɛ*_{r} and *μ*_{r} values of the object above a certain threshold value. Therefore, a more accurate and flexible PINN approach needs to be developed where the loss weights in Eq. (2) are not fixed but can be adaptively modified for the solution of high-index problems. In this section, we, in fact, demonstrate that additionally training the PINNs’ loss weights significantly improves the accuracy of the parameter retrieval for high-index scattering objects. It has been recently demonstrated that adaptive PINN methods can outperform standard PINNs in accurately solving PDEs with solutions containing sharp transition and sudden fronts, such as the situations encountered in phase-field PDEs.^{46–48} The basic idea behind adaptive PINNs is to increase the loss weights for the loss terms that are high. In particular, we apply the following updates for the loss weights at the *k*th time of *n* iterations in addition to the standard PINNs:

where *η* is the learning rate for the loss weights. We choose the cylinder with the same geometry as in Sec. II A 1 with *ɛ*_{r} = 5 + *j*(1) and show in Sec. 2.6 of the supplementary material that the standard PINNs fail to retrieve.

The complex *ɛ*_{r} retrieval results with respect to the iteration number by using the standard PINNs (*ɛ*_{r2,na}) and adaptive PINNs (*ɛ*_{r2,a}) are compared in Fig. 9(a). The same FEM simulation and normal PINN setup as in Sec. II A 1 are used. For the adaptive PINNs, we choose *η* = 5 and update the loss weights by every 5000 iterations (*n* = 5000). We use the fixed loss weight values in standard PINNs as the initial loss weight values for the adaptive PINNs. Further training details are specified in Sec. IV. We observe that at the beginning of the training process, *ɛ*_{r2,a} and *ɛ*_{r2,na} are close because the initial loss weights for the adaptive PINNs are the same as the fixed loss weights for the standard PINNs. However, as the simulation progresses further, *ɛ*_{r2,a} converges to its correct value, and this value is very different from *ɛ*_{r2,na} at the end of the simulation due to the importance of the loss weight updates. We show the reconstructed complex *E*_{z} real and imaginary profiles in Figs. 9(b) and 9(c) by using adaptive PINNs, respectively. The *L*^{2} errors with respect to FEM solutions of the *E*_{z} profiles obtained from PINNs are now as low as 1 × 10^{−4} and 2 × 10^{−4} for the real and imaginary parts, respectively. Therefore, the developed adaptive-PINN formulation is suitable for the study of the complex near-field profile of high-index scatterers and correctly retrieves their complex optical constants in situations where the standard PINNs loses their accuracy entirely. Furthermore, instead of applying the fixed loss weights with values determined using the trial and error procedure, the adaptive PINN method can balance the interplay between different loss terms automatically. We demonstrated parameter retrieval for a high-index material by using the adaptive PINNs to improve the retrieval accuracy in a 2D configuration. In Sec. IV of our paper, we introduce the implementation of the general PINN model for complex parameter retrieval of 3D objects with unknown shapes.

### D. Complex permittivity retrieval of 3D objects with unknown shapes

We finally extend the PINN framework to retrieve the complex permittivity of 3D objects with unknown shapes and composition, which directly addresses the inverse retrieval of optical parameters of nanostructures used in practical biomedical and nanotechnology applications. As a representative example, we show the 3D retrieval of the permittivity profile of non-magnetic objects. However, the presented framework can be modified as shown in Sec. II A–II C to additionally retrieve the complex *ɛ*_{r} and *μ*_{r} 3D profiles simultaneously. By training with the complex electric field data in 3D space and restricting the search based on the wave equation for 3D non-homogeneous media, we demonstrate that PINNs can successfully retrieve the complex permittivity of 3D objects. The implemented non-homogeneous wave equations for non-magnetic objects can be derived from Eq. (6) as

We consider here a 3D sphere with radius *r*_{1} = 2 *µ*m and constant relative permittivity *ɛ*_{r1} = 3. The complex electric field data **E** = (*E*_{x}, *E*_{y}, *E*_{z}) obtained from 3D FEM simulations under plane wave illumination with wavelength *λ* = 3 *µ*m are used as the complex field observations to train PINNs. We display the 3D electric field real part profiles for training PINNs in Figs. 10(a)–10(c). We employ a FCNN and train it over 120 000 iterations until the total loss is below 10^{−1}. Additional details on the 3D FEM simulations and the network parameters are discussed in our Sec. IV. The retrieved 3D permittivity is shown in Fig. 10(d). The obtained non-homogeneous permittivity inside the 3D sphere region is *ɛ*_{r} = 2.57 ± 0.45, which is in qualitatively good agreement with the ground truth value *ɛ*_{1}. This result, which is only limited by our available computational power (we intentionally used a desktop computer for conducting this work as specified in Sec. IV), can be further improved by increasing the sampling points for the electric fields in 3D. We conclude by remarking that a similar approach can be applied to extend this PINN framework for the simultaneous 3D retrieval of *ɛ*_{r} and *μ*_{r} based on 3D near-field microscopy data.

## III. CONCLUSION

In conclusion, we have introduced a general DL framework for solving PDEs using PINNs to inversely retrieve unknown 2D and 3D electric and magnetic material parameters and shape information from synthetic field data. Our results are particularly interesting for inverse microscopy given the current availability of experimental near-field techniques that can measure the optical phase in the near zone with nanoscale resolution. By considering different complex PDE models and field data obtained from FEM simulations, we used PINNs to demonstrate successful retrieval of the complex *ɛ*_{r}(*x*, *y*) and *μ*_{r}(*x*, *y*) profiles simultaneously and with very good accuracy. We emphasize that this is achieved within the physics-informed method with significantly reduced data collection and training requirements compared to traditional machine learning approaches that typically employ massive datasets. We presented PINN-based parameter retrieval models that work under both extended and localized excitations that are typically used in SNOM applications. We then proposed and demonstrated an adaptive-PINN algorithm for improving the accuracy of the parameter retrieval for high-index materials. Finally, we showed a successful application of PINNs to the retrieval of the complex permittivity of a 3D scattering object with an unknown shape. The developed approach can be naturally scaled to any wavelength of interest and applied in arbitrary geometries, providing novel opportunities for non-invasive remote sensing techniques based on measured field data. The proposed computational framework can naturally enhance existing imaging techniques for the detection of magnetic nanoparticles used in cancer therapy and drug delivery^{38–40} and can be utilized for inspecting and characterizing complex optical devices based on acquired images.^{49} Although in this paper we were concerned with implementations of PINNs based on complex field data, phase retrieval techniques that recover the phase information from intensity measurements can be used to solve more general intensity-based (phase-less) retrieval problems with near-field imaging techniques.^{50–52}

## IV. METHODS

### A. FEM simulations

The complex electric field and magnetic field data are obtained by solving the forward scattering problem using the finite element method.^{53} For the 2D examples, we used a minimum element size of 0.6 nm and a perfectly matching layer (PML) boundary with a thickness of 3 *μ*m surrounding the square domain Ω of side length 10 *µ*m. The total degrees of freedom of resulting FEM models are around 200 000. We implemented a scattered field formulation and set the background electric field as the plane wave propagating from left to right in the domain Ω. The complex field data are sampled on a 200 × 200 grid point in Ω.^{31}

The same minimum element size and PML boundary thickness are used for solving the 3D forward scattering problem. The degrees of freedom of the 3D FEM model are $\u223c700000$. The incident plane wave propagates along the x-axis with the electric field polarized along the *z*-axis. We sampled the complex electric fields on a 3D grid with point numbers 50 × 50 × 30 along *x*-, *y*-, and *z*-axes, respectively. This provides a minimum size of the computational grid equal to 200 × 200 × 333 nm^{3} along *x*-, *y*-, and *z*-axes, respectively.

### B. Neural network architecture and training hyperparameters

In all simulations except for the 3D retrieval case, a FCNN with four hidden layers and 64 neurons in each hidden layer is trained. We used a FCNN with three hidden layers with 20 neurons in each hidden layer for the 3D parameter retrieval. For all the PINNs discussed, we set the learning rate as 10^{−3}. We fixed *w*_{i} = 100 in the training process for a better convergence to the input field data for the standard PINNs. The adaptive PINNs used *w*_{f} = 1, *w*_{b} = 1, and *w*_{i} = 100 as the initial loss weights. Notice that we use the same hyperparameter values when addressing different problems, which demonstrates the robustness of our methodology for solving parameter retrieval for microscopy. We choose the hyperbolic tangent function as the activation function. The Glorot uniform method is used for the ANN weights and bias initialization. The Adam optimizer is used for training the ANN.

The training process is implemented on a desktop with an Intel i7-8700K central processing unit (CPU) at 3.70 GHz and 32 Gb of RAM using a Nvidia GeForce GTX 1080Ti graphics processing unit (GPU). A typical training process for the FCNN takes around 10 h.

## SUPPLEMENTARY MATERIAL

See the supplementary material for additional information.

## ACKNOWLEDGMENTS

L.D.N. acknowledges the support from the Army Research Laboratory (ARL; Cooperative Agreement No. W911NF-12-2-0023) and the National Science Foundation (Grant No. ECCS-2015700). The authors would like to thank Dr. Lu Lu and Professor George Em Karniadakis from Brown University for introducing us to the general methodology of PINNs and for insightful discussions.

## AUTHOR DECLARATIONS

### Conflict of Interest

The authors have no conflicts to disclose.

## DATA AVAILABILITY

The data that support the findings of this study are available from the corresponding author upon reasonable request.