A Neural Network Assisted $^{171}$Yb$^{+}$ Quantum Magnetometer

A versatile magnetometer must deliver a readable response when exposed to target fields in a wide range of parameters. In this work, we experimentally demonstrate that the combination of $^{171}$Yb$^{+}$ atomic sensors with adequately trained neural networks enables to investigate target fields in distinct challenging scenarios. In particular, we characterize radio frequency (RF) fields in the presence of large shot noise, including the limit case of continuous data acquisition via single-shot measurements. Furthermore, by incorporating neural networks we significantly extend the working regime of atomic magnetometers into scenarios in which the RF driving induces responses beyond their standard harmonic behavior. Our results indicate the benefits to integrate neural networks at the data processing stage of general quantum sensing tasks to decipher the information contained in the sensor responses.


INTRODUCTION
Quantum sensing 1 and metrology 2 are important branches of modern quantum technologies with applications in different areas such as imaging 3,4 and spectroscopy [5][6][7] . In this scenario, atomicsized sensors encoded in 171 Yb +8-12 and 40 Ca +13 ions provide spatial resolution and sensitivity for the detection of external/ target fields. In addition, 171 Yb + ions exhibit negligible emission rates 11 and extended coherence times due to the stabilization provided by dynamical decoupling (DD) techniques [14][15][16] . In particular, DD methods that exploit the multi-level structure in the 2 S1 2 manifold of the 171 Yb + ion have to lead to the detection of radio frequency (RF) fields with sensitivity close to the standard quantum limit 9 , while the resulting dressed state qubit was proposed as a robust register for quantum information processing 8,10 . However, this approach is restricted to a narrow working regime leading to harmonic sensor responses where RF target parameters are encoded. A departure from such a range leads to complex sensor responses where standard inference of the external fields gets challenging. In another vein, machine learning (ML) tools are incorporated to address distinct problems in quantum technologies. In particular, neural networks (NNs) are valuable in distinct quantum sensing scenarios leading to adaptive protocols for phase estimation [17][18][19] , parameter estimation [20][21][22][23][24] , and quantum sensors calibration [25][26][27] .
In this article, we experimentally demonstrate the ability of NNs to decode complex sensor responses, thus significantly extending the operational regime of quantum detectors. In particular, we infer RF target parameters from the measured response of an 171 Yb + atomic sensor in distinct challenging scenarios. These comprise the regime of non-harmonic sensor responses with large shot noise, and the continous interrogation of the sensor (via single-shot measurements) under always-on RF fields. With careful modeling of the sensor-target dynamics, we train NNs to relate intricate responses of the sensor with RF parameters leading to estimations of the latter with high accuracy.

The quantum sensor
The sensor consists of four hyperfine levels ( 0 j i; 0 ; 1 j i, and À1 j i) in the 2 S1 2 manifold of the 171 Yb + ion, and in a static magnetic field B z . To enhance the coherence of the sensor, we use two microwave (MW) fields with Rabi frequency Ω leading to the dressed basis set f u which is insensitive to magnetic field fluctuations 8,9 , see Fig. 1a, b.
Once a target field Ω tg cosðω tg t þ ϕ tg Þ is applied, one measures the dark state ( D j i) survival probability P D (t) considered here as the sensor response. The standard working regime of the sensor (leading to harmonic responses) implies Ω tg ≪ Ω ≪ ω tg with ω tg resonant with, e.g., the 0 $ 1 j i transition 9 . This simplifies the total Hamiltonian (see Supplementary Note 1) into From Eq. (1) one finds the harmonic sensor response P D ðtÞ ¼ cos 2 ðπt=t R Þ, with t R ¼ 2π ffiffi ffi 2 p =Ω tg establishing a simple relation between t R and the target field parameter Ω tg . In contrast, a departure from the standard working regime leads to the loss of this type of simple dependencies between sensor responses and target parameters, thus posing serious challenges for reliable field characterization. We demonstrate that our setup combining a quantum sensor and NNs can extract RF fields parameters from complex sensor responses.

Experimental setup
As schematically shown in Fig. 1c, our protocol is executed on a single 171 Yb + ion confined in a Paul trap which is shielded by permalloy to reduce the surrounding magnetic noise 28,29 . A magnetic field B z is applied to the ion leading to a Zeeman shift ≈10.0 MHz between 0 and 1 j i. Two~12.6 GHz MW fields Ω j cosðω j t þ ϕ j Þðj ¼ 1; 2Þ, respectively resonant with transitions 0 j i $ 1 j i and 0 j i $ À1 j i are used for state manipulation. To generate the dark state D j i, we design pulses with the amplitudes Ω 1 and Ω 2 evolving in the form of a hyperbolic tangent (details available in Supplementary Note 2). During the sensing window, the amplitudes of dressing fields are kept constant at Ω 1 = Ω 2 = (2π) × 5.5 kHz. Afterwards the state remaining in D j i is transferred to 0 j i for detection. A copper coil placed under the trap generates the target field once an RF current is sent to the coil. As the original RF signal is produced by an arbitrary waveform generator (AWG2), the amplitude, frequency, and the initial phase of the target field can be set by adjusting the parameters of AWG2. An RF switch is placed after the AWG2 output in order to remove interaction between the field and the ion if necessary while keeping the signal source continuously on. After amplification, the RF target field generated by the coil has a maximum amplitude of Ω max tg ¼ ð2πÞ 9:0 kHz. A photomultiplier tube (PMT) is used to detect the state-dependent fluorescence. As schematically shown in Fig. 1d, the response from PMT, i.e., X, is processed through the well-trained NN leading to the outputs Y which approach the targets A. We use data generated from numerical simulations to create the NN. Then, by inputting experimentally collected responses into the NN, we estimate the RF parameters. Now, we demonstrate the good performance of an 171 Yb + -magnetometer assisted by a NN in two scenarios in which input data comprise (i) average values obtained from a reduced number of measurements, and (ii) binary sequences (including only 0, or 1) continuously acquired from single-shot measurements. Both cases are demonstrated in regimes where the sensor delivers complex responses that depart from the standard harmonic regime. Hence, we prove that NNs significantly extends the versatility of quantum sensors.

Scenario i: Parameter estimation with a reduced number of measurements
We aim to estimate the Rabi frequency of a target field. In this case, the input data string X ¼ fP 1 ; P 2 ; :::; P Np g consist of the average values P i (i ∈ [1, N p ]) collected at N p time instants t = t i distributed in a time interval [0, t f ] for a specific Ω tg . We use the Hamiltonian in Supplementary Note 1 to numerically compute P D (t i ), as each P i does not follow the expression P D ðt i Þ ¼ cos 2 ðπt i =t R Þ in cases that depart from the standard working regime. In addition, the binary outcome is drawn from a Bernoulli distribution z i n $ Bð1; P D ðt i ÞÞ 2 f0; 1g such that each simulated average value is We choose N p = 151, N m = 100 and t f = 2.828 ms (note that this value of t f corresponds to one period of the sensor response for In particular, we harvest sensor responses for N = 15 values of Ω tg (while we select other RF parameters as ϕ tg = 0 and ω tg = (2π) × 10.56 MHz) which do not belong to the training/ validation/test datasets, and for a number of shots N m = 100, and N m = 30. In Table 1, we list the estimations y 1 from the NN for each target a 1 ≡ Ω tg . Each output y 1 is obtained after feeding the NN Fig. 1 Schematic levels of the 171 Yb + atomic sensor and the experimental setup. a Relevant levels of the 171 Yb + atomic sensor. Two resonant MW fields drive the sensor with a Rabi frequency Ω leading to the configuration in (b) which is defined in the dressed state basis f u j i; d j i; 0 ; D j ig 9 . c Schematic configuration of the experimental setup. The ion is trapped in a needle trap which consists of a pair of RF electrodes and four DC electrodes. The MW fields for state manipulation are generated by mixing a 12.4428 GHz signal with the signal from an arbitrary waveform generator (AWG1). The 12.6 GHz signal after a high pass filter (HPF) is amplified by an amplifier (Amp1) and sent to the ion using a MW horn outside the vacuum chamber. The target field around 10 MHz is generated by another arbitrary waveform generator (AWG2) controlled by the computer and broadcast to the ion through a coil after amplification. We place an extra RF switch after AWG2, which can be used to remove the target field from the trap while keeping the signal from AWG2 continuous. A photomultiplier tube (PMT) is used to detect the state-dependent fluorescence. d Scheme of the NN. The response from PMT, i.e., X, is processed by a number of hidden layers (HL 1 ... HL k ) leading to the outputs Y.  Fig. 2a, b. The average accuracy in the estimation of the different Ω tg is defined as F ¼ 1 N P N j¼1 F j , with F j ¼ 1 À jy j 1 À a j 1 j=a j 1 , and a 1 = Ω tg . With the values in Table 1 we find the results F ¼ 98:76% for N m = 100 with a standard deviation (SD) of the F j set SD = 0.7762%. In the case of N m = 30, we find F ¼ 98:31% with SD = 1.1483%. We remark that these highly accurate estimations were obtained with examples that comprise values of Ω tg leading to sensor responses that depart from the harmonic case. In particular, in Fig. 2 (c,d,e) we show the cases for Ω tg = (2π) 1.1487 1.1487 kHz (c) and Ω tg = (2π) × 8.9493 kHz (d, e), leading to harmonic and non-harmonic responses respectively (both cases comprise N m = 30). On the one hand, in Fig. 2c, we show that the sensor response (diamonds) follows the harmonic function P D ðtÞ ¼ cos 2 ðπt=t R Þ (blue-solid line). On the other hand, in Fig.  2d, one can observe that the response (diamonds) deviates from the harmonic case, while Fig. 2e shows that the same response fits to a non-harmonic function (red-solid curve) obtained via numerical simulations of the Hamiltonian (see Supplementary Note 1). By introducing these two responses into our NN, we get the outputs y 1 = (2π) × 1.1731 kHz and y 1 = (2π) × 8.7825 kHz which result in large accuracies F = |y 1 − a 1 |/ a 1 = 97.84%, 98.14%, respectively. In Supplementary Note 4, we show further examples including both Rabi frequency Ω tg and potential detunings ξ between the target frequency and the sensor hyperfine transition.
Scenario ii: Continuous data acquisition Now, we consider a scenario that comprises single-shot measurements on the ion (i.e., N m = 1). This scheme is relevant in situations where no reinitialization of the RF field is possible. We demonstrate that the estimation of RF parameters is still feasible in these conditions. We get one binary value from the atomic sensor (0 or 1) after completing the three experimental stages illustrated in Fig. 3a. More specifically, at stage 1 we cool the ion and prepare the D j i state in a time t 1 = 6.097 ms. At stage 2 the ion is allowed to interact with the target field for a time t 2 ∈ [0, 6] ms. At stage 3, we readout the ion in a time t 3 = 2.447 ms. We repeat these three stages 251 times (leading to a binary string comprising 251 numbers) where t 2 varies in the interval [0, 6] ms with a step 0.024 ms. Note that during the three stages the RF source is always on,   3 Estimation results from Scenario ii, continuous data acquisition. a Schematic configuration of the continuous data acquisition scheme. Each binary value is obtained after completing the preparation, interaction, and measurement stages. b-d Regression of the rescaled outputs y r 1 from the NN with respect to the targets a r 1 ¼ Ω r tg . The regression lines y r 1 ¼ αa r 1 þ β comprise b α = 0.9946, β = 0.0032, c α = 0.9932, β = 0.0040, d α = 0.9925, β = 0.0041, while the correlation coefficients R between the outputs and the targets are all larger than 0.999. All inputs X r , outputs Y r ¼ fy r 1 g, and targets A r ¼ fa r 1 g are rescaled into the range [0, 1].
thus to avoid potential damage on initialization and readout we switch the RF signal to a dummy load at stages 1 and 3. Via numerical simulations, we train a NN in accordance with the scheme in Fig. 3a. In particular, we use 96 values for Ω tg in the range (2π) × [0.5, 10] kHz (with a step of (2π) × 0.1 kHz) and repeat the data acquisition process 1800 times for each Ω tg . Thus we generate 96 × 1800 = 172,800 examples, of which 70%/ 15%/15% are used to build the training/validation/test datasets. After training the NN, we find the regression accuracy of the training/validation/test datasets shown in Fig. 3b-d. Note that data in Fig. 3b-d is rescaled into [0, 1] as this is a standardized procedure in NNs. Now, we experimentally obtain the sensor responses for 8 randomly chosen values of Ω tg in the range (2π) × [0.5, 10] kHz, which do not belong to the training/validation/test datasets (in addition, we select other RF parameters as ϕ tg = 0 and ω tg = (2π) × 10.03 MHz). We remark that the obtained responses range from the harmonic shape to those deviating from it. After 251 measurements for each Ω tg , we get binary strings including 251 numbers (0 or 1), where each number is obtained according to the scheme in Fig. 3a. When inputting each string into the trained NN, we get one output y 1 from the NN. In order to study the stability of the NN prediction, we have repeated 20 times the data acquisition for each Ω tg . In Table 2, we show the average value y 1 of the results from the NN and the SD based on 20 experimentally obtained strings.
In addition, the regression of the outputs y 1 with respect to the targets is in Fig. 4a. Finally, in Fig. 4b, we illustrate for a 1 = (2π) × 2.1572 kHz the histogram of the NN outputs y 1 obtained after feeding the NN with 20 strings of experimental data. The above analysis illustrates the ability of NNs to achieve accurate estimations in scenarios involving single-shot measurements (thus, when the RF field is not controllable), leading to highly versatile quantum sensors.

DISCUSSION
One can resort to other estimators for predicting parameters, e.g., using Bayesian inference. Following the well-known Bayes theorem, one may compute the posterior distribution p(Θ|X) ∝ p(X|Θ) p(Θ) where p(Θ), p(X|Θ) denote the prior and likelihood, respectively, while X refers to the data obtained by interrogating the quantum sensor at different time instances, and Θ = {θ 1 , . . . , θ k } denotes k unknown parameters which we aim to estimate by our quantum sensor. For a Bayesian estimator, an accurate microscopic model is needed in order to calculate the likelihood p(X|Θ).
More specifically, this is f ðx; n; pÞ ¼ n!
x!ðnÀxÞ!p x ð1ÀpÞ ðnÀxÞ ; (2) where the function f(x, n, p) refers to the probability of observing x success outcomes through n trials from the Binomial distribution with success probability p.P i ðt i ; ΘÞ is the survival probability P D computed using the total Hamiltonian H (see Supplementary Note 1: Eq. (3)) at time t i whose obtention requires to load a string of values for the Θ parameters in the microscopic model and then compute its dynamical evolution. Note this is a procedure that has to be repeated for each value of the Θ parameters. Finally, via the marginal distribution p(θ j |X) = ∫Π i≠j dθ i p(Θ|X), one could derive the average value and SD as In contrast, less prior knowledge of the microscopic model is needed when using NNs. This owes to NNs learning the input-output relation from the training/validation/test datasets that can be obtained from numerical simulations, or directly from experiments. The latter is especially useful when numerical simulation of the system dynamics becomes challenging (for instance, in a sensor that consists of several entangled ions).
In this manner, our work demonstrates the good performance in parameter estimation that results from an appropriate hybridization of ML tools with quantum sensing techniques. This is a strategy that can be easily extended to other quantum platforms, such as, e.g., nitrogen-vacancy (NV) centers in diamond, to decipher complex NV responses emerging from dense nuclear samples comprising nuclear spins which are strongly coupled to the sensor and/or among them.

NN-based magnetometer
A NN enables to find the relation between N p measured data X ¼ fx 1 ; x 2 ; :::; x Np g, and n output data Y = {y 1 , y 2 , . . . y n } that approach the targets A = {a 1 , a 2 , . . . , a n }. During the training stage of the NN, the following cost function is minimized for a training set that comprises N examples. This is done by using gradient descent methods such that the NN parameters (i.e., weights and biases) are adjusted to satisfy F(X) = Y ≈ A.
In our case, we deal with an 171 Yb + -magnetometer where we aim to estimate RF parameters from experimentally collected responses by inputting them into the NN. The input data contains, in Scenario i, average values obtained from a reduced number of measurements and, in Scenario ii, a sequence containing binary values continuously acquired from single-shot measurements. For the first case, the input data string X ¼ fP 1 ; P 2 ; :::; P Np g consist on the average values P i (i ∈ [1, N p ]) collected in a time interval [0, t f ] for a specific set of targets A. The simulated average value is P i ¼ P Nm n¼1 z i n =N m for a number of shots N m , where the binary outcome is drawn from a Bernoulli distribution z i n $ Bð1; P D ðt i ÞÞ 2 f0; 1g. In the second scenario that comprises continuous data acquisition, the input data string X is made of binary numbers, 0 and 1, which are obtained according to the scheme in Fig. 3a Experimental timing sequence As shown in Fig. 5, in each cycle (each period to obtain one value P i (i ∈ [1, N P ]) of a response / input data string), the ion is cooled down approximately in the Doppler limit by a red-detuning 369.5 nm laser starting from stage 1. After that, the state of the ion is initialized to 0 j i by an optical pumping process. After a 0.5 μs 'MW trigger' signal, a MW π-pulse resonant with 0 j i $ 1 j i transfers the state from 0 j i to 1 j i. Subsequently, the STIRAP pulses drive the system from the state 1 j i to the dark state D j i. At stage 2, the amplitudes of MW fields are held at a constant Ω within the fixed time interval [0, t D ]. Simultaneously, the target RF field is applied for the time interval [0, t 2 ], where t 2 ≤ t D . For the scheme of a finite number of measurements (Scenario i), after the time instant t 2 , the RF field is removed by turning off the AWG2 output. The RF target field is restarted at the next cycle such that the repetition of measurement can be done. For the scheme of single-shot measurement, Scenario ii, the RF signal is switched to a dummy load after the time instant t 2 while the origin RF source is always on. At stage 3, the STIRAP pulses transfer the rest of population of D j i back to 1 j i. Another π-pulse transfers the population of state 1 j i to 0 j i. Thus, we can get the response of D j i by measuring the probability of 0 j i, and a state dependent fluorescence detection could be used to determine it. Before and after the cycle, there are extra 'idle' steps (1 μs) needed to end this cycle and start the next cycle. In our experiments, the timings are all controlled by a TTL pulse generator (Spincore PB24-100-4k-PCIe) see Table 3 for the specific values of the time intervals invested in each process. The sequence diagram of the experiment. The whole cycle could be divided into three stages. Stage 1 consists of cooling, initialization, and preparation of the state 1 j i (the first blue zone) and the state D j i (the first green zone). At Stage 2 (the pink zone of length t D ), we allow the ion interacts with the target field at the interval [0, t 2 ] (the yellow zone), where t 2 ≤ t D . In stage 3, we transfer the state D j i back to 0 j i and detect the probability of 0 j i.