Adaptive Machine Learning for Time-Varying Systems: Low Dimensional Latent Space Tuning

Machine learning (ML) tools such as encoder-decoder convolutional neural networks (CNN) can represent incredibly complex nonlinear functions which map between combinations of images and scalars. For example, CNNs can be used to map combinations of accelerator parameters and images which are 2D projections of the 6D phase space distributions of charged particle beams as they are transported between various particle accelerator locations. Despite their strengths, applying ML to time-varying systems, or systems with shifting distributions, is an open problem, especially for large systems for which collecting new data for re-training is impractical or interrupts operations. Particle accelerators are one example of large time-varying systems for which collecting detailed training data requires lengthy dedicated beam measurements which may no longer be available during regular operations. We present a recently developed method of adaptive ML for time-varying systems. Our approach is to map very high (N>100k) dimensional inputs (a combination of scalar parameters and images) into the low dimensional (N~2) latent space at the output of the encoder section of an encoder-decoder CNN. We then actively tune the low dimensional latent space-based representation of complex system dynamics by the addition of an adaptively tuned feedback vector directly before the decoder sections builds back up to our image-based high-dimensional phase space density representations. This method allows us to learn correlations within and to quickly tune the characteristics of incredibly high parameter systems and to track their evolution in real time based on feedback without massive new data sets for re-training.


Introduction
New advanced particle accelerators are being designed and operated with the goal of finer control over the phase space of the accelerated beams than what has previously been achieved. At advanced light sources such as the Linac Coherent Light Source (LCLS) upgrade, LCLS-II two color mode operation is being developed in which the energies of two bunches separated by tens of femtoseconds are precisely controlled to generate x-rays with precisely tuned energy differences [1]. At the Swiss-FEL a two color mode is also being developed and advanced nonlinear compression techniques have enabled the production of attosecond hard x-ray FEL pulses [2]. The EuXFEL is utilizing advanced superconducting radio frequency (RF) cavities and low level RF controls to accelerate bunches at MHz repetition rates [3]. The plasma wakefield acceleration facility for advanced accelerator experimental tests (FACET) upgrade, FACET-II, is planning on providing custom tailored current profiles with fs-long bunches and hundreds to thousands of kA peak currents [4]. At CERN's Advanced Proton Driven Plasma Wake-field Acceleration Experiment (AWAKE) facility the goal is to use transversely focused high intensity (3 × 10 11 ), high energy (400 GeV) protons from CERN's Super Proton Synchrotron (SPS) accelerator to create a 10 meter long plasma and wake-fields into which 18.8 MeV 650 pC electron bunches will be injected and accelerated up to 2 GeV [5].
The control of intense charged particle beams is challenging due to complex collective effects such as space charge forces and coherent synchrotron radiation (CSR) which severely distort the 6D phase space ( , , , , , ) of intense bunches, especially during bunch compression. One of the main challenges of beam control is a lack of detailed real-time phase space diagnostics. To achieve more precise control of intense charged particle beams requires the development of new and higher resolution non-invasive beam diagnostics as well as new advanced adaptive control methods which utilize the data from these diagnostics. The vast majority of online real-time bunch-tobunch beam measurements provide scalar data such as beam position centroids from beam position monitors or beam averaged charge from current monitors.

Limitations of Machine Learning for Time-Varying Systems
Machine learning (ML) tools are being developed that can learn representations of complex accelerator dynamics directly from data. ML methods have been utilized to develop surrogate models/virtual diagnostics [6][7][8], neural networks are being used to represent cost functions or optimal policies in reinforcement learning [9], powerful polynomial chaos expansion-based surrogate models have been used for uncertainty quantification [10], an interesting analysis of the latent space of neural network-based surrogate models has been used for uncertainty quantification [11], convolutional neural networks have been used for time-series classification and forecasting in accelerators [12], neural network-based surrogate models have been used to speed up optimization [13,14], Bayessian Gaussian processes utilize learned correlations in data/physics-informed kernels [15][16][17][18][19][20][21][22], and various ML methods have been used for beam dynamics studies at CERN [23][24][25].
One limitation of ML methods, and an active area or research in the ML community, is the problem of time-varying systems, known as distribution shift. If a system changes with time then the data that was used to train an ML-based tool will no longer provide an accurate representation of the system of interest, and the accuracy of the ML tool will degrade. Distribution drift is a challenge for all ML methods including neural networks for surrogate models, the use of neural networks to represent cost functions or optimal policies in reinforcement learning, and even for methods such as Gaussian processes which utilize learned correlations in their kernels.

Adaptive Feedback for Time-Varying Systems
In order to handle time-varying systems one must utilize feedback which enables real-time adjustments based on measurements. Powerful model-independent feedback control techniques have been developed to automatically compensate for un-modeled disturbances and time-varying system dynamics for unknown, time-varying, high dimensional systems [26]. The limitation of most adaptive feedback methods is that they are local in nature and therefore can become stuck in local minima or may converge very slowly if their initial conditions are chosen extremely far away from the optimum in a large parameter space.

Adaptive Machine Learning for Time-Varying Systems
Efforts have begun to combine the robustness of adaptive feedback with the global representations that can be learned with ML methods to develop adaptive machine learning (AML) for time-varying systems. The first such result combined neural networks and model-independent feedback to provide fast, robust, and automatic control over the energy vs time phase space of electron bunches in the LCLS [27]. Recently, AML methods have been studied in more generality for adaptive tuning of the inputs and outputs of ML tools such as neural networks for time-varying systems [28].

Summary of Main Results: Adaptive Latent Space Tuning
Adaptive latent space tuning maps high dimension inputs down to extremely low dimensional latent space representations of generative encoder-decoder style convolutional neural networks (CNN) [29,30]. In this work we demonstrate an approach in which an encoder-decoder CNN's input is a combination of a 7-dimensional vector representing several particle accelerator components as well as a 128×128 pixel image which is the initial ( , ) phase space density of an electron beam entering the FACET-II accelerator. The overall input dimension of this system, in = 16391, is then mapped down to a latent space dimension as low as = 2 by the encoder half of the CNN before the generative half builds back up to a 128×128×75 pixel representation of the beam ( out ≈1.2e6) which are all 15 of the unique 2D 128×128 pixel projections of the 6D phase space of the beam at 5 different locations within the FACET-II accelerator, as shown in Figure 1.
By simultaneously predicting 75 phase space projections we are effectively forcing the CNN to satisfy a large number of physics constraints. This low-dimensional latent space representation can be quickly adaptively tuned based only on a comparison of a single one of the 75 output distributions, the position vs energy longitudinal phase space prediction which is available for measurement at many accelerators via transverse deflecting cavities. After the network has been trained to learn the physics constraints within the system and the correlations between various parameters, it functions in an un-supervised fashion with one of the outputs compared to its measurement which then provides feedback to the latent space layer without need for measurements of an input beam distribution or knowledge of accelerator parameters which may drift. Because the network has learned to respect constraints and correlations it is able to predict the entire 6D phase space of the beam at 5 different locations. The feedback compensates for unknown time-varying input beam distributions and accelerator parameters. The low-dimensional latent space representation also informs the placement of limited numbers of diagnostics. The main results are summarized as: 1. An encoder-decoder generative convolutional neural network is trained using a supervised learning approach. The CNN takes as input the initial ( , ) input beam distribution and 7 accelerator parameters which are beam and offsets, charge, and the amplitudes and phases of the first 2 linear acceleration sections of FACET-II. The CNN pinches down to a low dimensional latent space before the generative half of the CNN outputs all 15 unique projections of the beam's 6D phase space at 5 different accelerator locations as in Figure 1.
2. Once the CNN is trained, we operate in an adaptive un-supervised manner in which we no longer need access to the 7 accelerator parameters or to the initial beam distribution. Our adaptive approach compares the CNN's prediction of the position vs energy ( , ) phase space to transverse deflecting cavity measurements and adaptively tunes the latent space in order to track unknown time-varying beams and accelerator parameters.
3. The CNN is able to predict all of the 2D phase space projections because it has learned the physics relationships and correlations within the system.

Robust Feedback Control for Particle Accelerators
Particle accelerators are large systems with thousands of coupled components and complex charged particle dynamics. Accelerators and beams are time varying due to external disturbances, misalignments, and time variation of both the accelerator beam sources as well as of the RF and magnet components such as phase shifts in RF cables. The time variation and complexity of accelerator systems results in time varying input-output relationships, where we refer to inputs as component settings, such as magnet power supply currents or RF accelerating voltages, and outputs as beam characteristics such as beam spill and the beam's 6D phase space distribution. Because of the complexity and variability, the performance of standard model-based controls is limited and drifts with time. Although individual components can be kept at their desired set points very precisely, the overall system dynamics drifts as it depends on the relationships between various components and the beam. Model-independent feedback methods are a major subject of research in control theory where robustness to un-modeled disturbances and changes to system dynamics is an important consideration. For example, consider the scalar linear system where the values of and are unknown. Such a system cannot be stabilized with simple proportional integral derivative (PID)-type feedback, but if the sign of is known, for example if > 0, a stable equilibrium of (2.1) can be established at = 0 by the following nonlinear controller This approach is robust as it does not depend on a detailed knowledge of system dynamics, which is important in practice because all models are only approximations. However, two major limitations of such an approach are: 1). The sign of the unknown term must be known and cannot be timevarying. 2). The presence of an arbitrarily small un-modeled disturbance in the dynamics (2.1) can destabilize the closed loop nonlinear system. Over the last decades, many more sophisticated nonlinear and adaptive feedback control algorithms have been developed which are robust to a wide range of un-modeled disturbances and are applicable to time-varying systems [31][32][33]. A limitation of nonlinear and adaptive control approaches was an inability to handle a signchanging time varying coefficient ( ) in system (2.1) which multiplies the control input ( ), such as ( ) = cos(2 ) which changes sign repeatedly thereby changing the effect of control input ( ). For particle accelerators such variation is important. For example, consider a state ( ) which describes beam loss in a particle accelerator, whose minimization is desired, which is influenced by a large collection of quadrupole magnets u = ( 1 , . . . , ). The effect of a single magnet, , depends on the initial beam's phase space as it enters the accelerator from the source and also on the settings of all of the other quadrupole magnets that are upstream, < and changes with time as the upstream magnets are adjusted and as the initial beam conditions change. One day decreasing may require decreasing the current of magnet and another day it might have to be increased. Recently, a nonlinear extremum seeking (ES) feedback control method was developed which could stabilize and minimize the analytically unknown outputs of a wide range of dynamics systems, scalar and vector-valued which can be time-varying, nonlinear and open loop unstable with unknown control directions [26,34]. The ES method is applicable to a wide range of systems of the form which include scalar time-varying linear systems, vector-valued time-varying linear systems, and vector-valued nonlinear time-varying systems, where in each case the feedback control is based only on a noise-corrupted measurementˆ( ) of an analytically unknown cost function (x, ). For example, a measurable but analytically unknown cost function an be the sum of beam loss along a many kilometer long particle accelerator, which depends on all accelerator parameters and on the initial 6D phase space of the beam being accelerated. Relative to accelerator applications, the ES method is used to tune groups of accelerator parameters, p = ( 1 , . . . , ), which may be a subset of the state space x which describes the overall accelerator dynamics. For example, tuned parameters might include RF cavity amplitude and phase set points as well as magnet power supply voltages or currents. The adaptive ES algorithm dynamically tunes parameters according to where are distinct dithering frequencies defined as = with ≠ for ≠ , is a feedback gain. The may be chosen from a large class of functions which may be non-differentiable and not even continuous, such as square waves which are easily implemented in digital systems [35]. The only requirements on the are that for a given time interval [0, ] they are measurable with respect to the 2 norm and that they are mutually orthogonal in Hilbert space in the weak sense relative to all measurable functions ( ) ∈ 2 [0, ] in the limit as → ∞, which can be written as One particular implementation of the ES method is especially convenient for particle accelerator applications because the tuning functions have analytically guaranteed bounds despite acting on analytically unknown and noisy functions, which guaranteed known update rates and limits on all tuned parameters. This bounded form of ES was first developed for accelerator tuning [36], and then studied for dynamic systems in general [37] and takes the simple form The utility of this approach is clearly demonstrated by considering a system of the form which results in average dynamics that minimize the noise-corrupted unknown function (x, ):

Adaptive Machine Learning: Latent Space Tuning
Convolutional neural networks (CNN) are some of the most powerful machine learning (ML) tools which regularly outperform all other methods in complex high-dimensional tasks such as image classification where, for example, using 100×100 pixel photos results in a 10 4 dimensional input space [38]. The main challenge in utilizing ML approaches for particle accelerator beams is the fact that accelerator components and beam initial conditions change unpredictably with time degrading the accuracy of any data-based ML approach to virtual diagnostics. Figure 2. An encoder-decoder AML setup is shown in (A) where the inputs are stacks of images X , vectors of parameter values x 1 , and an adaptively tuned latent space input vector y , while the output is another stack of images Y . A simplified diagram of the same setup is shown in (B). For adaptive tuning, a measurement of the network's output, Y , is compared to an available measurement M, based on which the adaptive update y is created to adjust the latent space representation y .
A new adaptive machine learning (AML) approach for time varying systems has recently been proposed in which model-independent adaptive feedback is used to tune the low dimensional latent space of encoder-decoder architecture convolutional neural networks (CNN) [29,30]. The encoder half of the CNN can use both images (initial beam distributions) and scalars (accelerator magnet and RF parameter settings) as inputs with the scalars being concated together with the information from the images once the images have been scaled down using 2D convolutional layers, flattened, and passed through dense fully connected layers.
The low dimensional latent space at the bottleneck of the encoder CNN is a general nonlinear transformation in which a trained CNN has found an incredibly efficient basis with which to represent beam properties, which may outperform purely linear dimensionality reduction techniques such as principal component analysis [39]. The CNN's decoder half can be used to generated predictions of beam phase space distributions as a function of the low-dimensional latent space whose parameters are easily adjustable due to the much lower dimension of the problem which may be orders of magnitude smaller than the many thousands of dimensions associated with large input images. An overview of the adaptive latent space approach is shown in Figure 3. During the initial training phase a supervised learning approach is taken in which the network uses input-output pairs (X , x , Y), where X may be collections of images which represent 2D projections of a particle accelerator beam's 6D phase space and the x are vectors of parameters such as magnet or RF system settings. The CNN's predictionˆof phase space projections is then compared to their true values Y so that a loss function (Ŷ, Y) is minimized by adjusting the CNN weights and biases (w, b) in a supervised training approach as shown in Figure 3A.
Once the network has been trained within its weights and activation functions are embedded the relationships and dependencies between the various components of the large outputˆ. The trained network is then utilized to make phase space predictions by looking at only those outputs which can be compared to measurements in real time,ˆ, to calculate some cost function (ˆ, ) which guides the adaptive tuning of an input to the latent space y according to the right hand side of Equation 2.6, as shown in Figure 3B. This approach has two major strengths. The first is that we are now tuning an incredibly high dimensional system within a much smaller space which greatly speeds up the convergence of any optimization or search algorithm. The second main benefit is that once we have learned the generative half of the CNN which is capable of generating complex high dimensional outputs as a function of a low dimensional latent space vector y we no longer need access to the original inputs that were used to train the network. This second feature is especially important for large complex systems, such as particle accelerators, where continuous operations makes it impossible to take detailed beam measurements without interrupting normal operations and therefore is only done during rare dedicated beam development times. The resulting algorithm is robust to uncertain time varying input beam distributions and accelerator parameters as they are assumed to be unknown and the application takes place as an adaptive un-supervised feedback approach which is only allowed to have access to measured quantities which may be a very small subset of all of the CNN's predictions. We demonstrate the approach on two very different particle accelerators: the HiRES compact ultrafast electron diffraction accelerator and the FACET-II plasma wakefield accelerator.

Application for Particle Accelerator Diagnostics
One of the most advanced and detailed diagnostics is a setup using a transverse deflecting RF cavity (TCAV) together with a dipole magnet which separates a beam horizontally as a function of time while separating it as a function of energy vertically resulting in a 2D projection of the beam's ( , ) longitudinal phase space (LPS) with fs resolution [40]. Accelerators such as the LCLS, have a TCAV directly after the undulator so that once the FEL lasing process has completed the remaining electron beam can be separated from the x-rays and the beam's LPS can be measured without disrupting FEL operations. Therefore at the LCLS the TCAV is an always present real-time non-invasive LPS diagnostics. Machines, such as the EuXFEL have their TCAV near the machine's beam source, so it can be used to get an estimate of the LPS characteristics of the beam entering the accelerator. Machines such as FACET-II might have multiple TCAVs, as shown in Figure 6, which can be used to periodically check the LPS properties of the beams throughout the accelerator.
The LPS of beams has a strong influence over their characteristics in terms of FEL lasing, bunch compression, and wakefield acceleration and therefore many recent efforts have been made for machine learning (ML)-based virtual LPS predictions to complement TCAV-based measurements by providing LPS estimates where TCAVs are not available or by providing LPS estimates without the use of destructive TCAVs. Tools for virtual phase space estimates have been developed which use model-independent adaptive feedback to adaptively tune physics models based on non-invasive beam measurements such as energy spread spectra [41]. Once an accurate estimate of a beam's LPS is obtained, whether by using a TCAV-based measurement or a virtual diagnostic, powerful adaptive feedback methods can be used to automatically control the LPS distribution [42], including combinations of ML and adaptive feedback for LPS control which is both global and robust to timevariation of accelerator and beam parameters [27].
A latent space tuning AML appraoch is developed for predicting all of the 2D projections of the beams entire 6D phase space given by the 15 distributions: 12  and the distributions are defined as It is usually difficult or impossible to measure the transverse phase space distributions 12 ( , ) and 34 ( , ) of the beam quickly and without interrupting operations. Our latent space approach provides an estimate of all 15 2D phase space projections in (4.1) by comparing the CNN's predictions of the LPS 56 ( , ) to available TCAV measurements and when possible also projecting was done in [41] to adaptive tune an online model to track the 56 ( , ) phase space non-invasively. This approach relies on the fact that the encoder-decoder CNN has learned correlations between the various phase space projections for a given accelerator lattice, as demonstrated below. By training the CNN over a wide range of beam and parameter characteristics, and by forcing the CNN to satisfy the many (15) physics constraints of the 2D phase space projections, the encoderdecoder did learn enough of the underlying beam physics so that it could be used in situations where the input beam distribution is no longer available, but only output beam TCAV-based measurements and possibly energy spread spectra measurements are available. Adaptively tuning the latent space allows us to use the encoder-decoder CNN without needing access to the original input parameter and distribution measurements with which the CNN was trained. This is a major advance for ML-based virtual diagnostics because outside of dedicated beam development times it is often very difficult to gather detailed measurements on input beam distributions in a non-invasive manner that does not interrupt accelerator operations. Figure 4 shows the results of training the encoder-decoder CNN with a 2D latent space layer. The figure shows the 2D latent space positions ( 1 , 2 ) of 500 test data sets which the CNN was not shown during training colored by the difference between the 56 ( , ) phase space projection of the beam at the first TCAV1 as shown in the schematic of FACET-II defined by the equation: Two points at opposite positions in the latent space are shown in red and black. As we move from the start to the goal point we see the evolution of the 13 ( , ) and 14 ( , ) projections at the location of TCAV1 and the 56 ( , ) projection at the interaction point (IP) location. We see that the encoder section of the CNN has sorted the beam in the latent space so that as we move along the green dashed line the transverse beam size is increasing, the beam divergence is flattening, and the bunch-to-bunch separation is squeezed down to a single bunch.

Latent Space Tuning for HiRES
It was first demonstrated in [30] that an adaptive latent space tuning approach was applied at the HiRES ultra fast electron diffraction compact accelerator whose schematic is shown in Figure 5. At HiRES the input distribution used was the ( , ) phase space projection at the electron gun and the accelerator parameters included magnet strengths and beam energy. The latent space tuning approach enabled measurements of the ( , ) longitudinal phase space to be mapped to the transverse phase space ( , ), ( , ) of the beam as shown in Figure 5.

Latent Space Tuning for FACET-II
For application to FACET-II, the X input in Figure 3 is a 128×128 pixel 2D 13 ( , ) distribution of the ( , ) phase space projection of the beam entering the particle accelerator and x is a vector of 7 accelerator and beam parameters which are the RF phase and amplitude settings, transverse beam offsets, and beam charge variation. The 16391 dimensional inputs (X , x ) are then combined into a single low-dimensional vector y of dimension between 2 and 100 before the generative half of the encoder-decoder CNN builds back up to a high dimensional outputŶ which is a 128×128×75 output with the 75 channels representing a set of 15 2D projections of the 6D phase space: ( , ),

2D Latent Space
The CNN was trained with twenty thousand randomly generated input-output pairs, over a wide range. By forcing the CNN to simultaneously predict all 15 2D distribution projections which must satisfy all of the physics constraints of both general relativistic electrodynamics as well as the specific constraints of the FACET-II setup, the correlations between the various phase spaces at FACET-II were learned. Various latent space dimensions were tested including 2, 7, and 100, and the statistics of test-set errors are shown in Figure 7. Clearly as the number of latent space dimensions is increased the accuracy of the CNN grows because the network size is bigger and the nonlinear representation is more general. However it is clear that after a dimension of 7 is reached the increase in accuracy is only incremental, which is understood by the fact that only 7 accelerator parameters were changed to create the training and test data for this demonstration.
The adaptive approach at FACET-II was to use an incorrect random (or it could just be the mean of all available measurements) guess for the input beam distribution and then iteratively adjust the low dimensional latent space to minimize a cost function which measured the difference between the predicted LPSˆ5 6 ( , ) and the correct LPS 56 ( , ) according to several candidate cost where , are costs based on TCAV measurements at the three TCAV locations considered for FACET-II and the , are costs based on non-invasive energy spread spectra measurements which could possibly be collected at each of the three bunch compressors.

Latent Space-Informed Diagnostics
For the 2D latent space CNN a pair of adaptive tuning results are shown in Figure 8. In Figure  8A-D, the cost being adaptively minimized is the sum 3

=1
, , and we see that the resulting cost function has a local minimum near the starting point in the 2D latent space, as shown in more detail in 8D. The result is that the adaptive scheme becomes stuck in this local minimum and is unable to reach the target. This counter-intuitive result can be understood by looking at Figure 4 where the IPˆ5 6 ( , ) phase space is shown, which is almost identical to the TCAV3 LPS. We can see that the way the CNN has sorted the 2D latent space, moving along the green dashed line from the starting to the goal position the bunch length is initially compressed and then spread out again before finally being compressed to a single bunch. This oscillating variation caused by including the TCAV3 measurementˆ5 6 ( , ) creates the local minimum in the cost function and a similar result happened with TCAV2. If we instead define the cost function to simply include only the TCAV1 LPS measurement, then we get the result shown in Figure 8E-H, where the local minimum has disappeared and so the adaptive optimizer is able to make its way across the entire range of the latent space in order to adaptively match the unknown beam.
This result is somewhat counter intuitive: using less information gives better convergence. One explanation is that FACET-II is such a large and complex machine that a given final beam phase space distribution can be created from many different initial distributions in a non-unique way based on all of the accelerator settings between the start and end of the machine. With this in mind it is understandable that the earlier diagnostics give a better chance of uniquely distinguishing between phase space distributions. This analysis shows that if a limited number of diagnostics must be chosen, such as placing a single TCAV at some location of an accelerator, it may be beneficial to place it earlier, as the measurements can be used to uniquely identify different beam characteristics. However there is of course an obvious downside to placing a diagnostic such as a TCAV too early in an accelerator configuration as one of the most useful applications of a TCAV is to measure the influence of collective effects such as space charge forces and CSR which grow in intensity as the beam reaches higher power and is compressed. Furthermore, although Figure 7 shows that the lower dimensional latent space results in less accurate results, Figure 8 shows the benefit of a low-dimensional latent space in that convergence is extremely fast, taking as few as 40 steps.

, > 2 latent space
Higher dimensional latent spaces result in more accurate CNN predictions, they also make it less likely to get stuck in a local minimum as it is easier to avoid local minima in a higher dimensional space. Figure 9 shows the results of tuning in a 3D latent space when using a cost which includes all of the TCAV and BC terms. The global minimum is reached by taking a wider path that avoids local minima. Figures 10,11 show tconvergence in a 7D latent space. Again the cost function includes all terms and the global minimum is reached with more space to avoid local minima. However, a major downside of increasing the latent space dimension is clearly seen in the growing number of steps required for convergence to take place. In practice there is a tradeoff between simplicity and accuracy/generality that must be made when choosing the latent space dimension for a given problem. Figure 12 shows the results of the 7D latent space convergence in Figures 10, 11. Figure 12 demonstrates that despite using only the projections measured for the cost functions , and , as defined above, the other 2D projections are also accurately predicted. We emphasize that the CNN is actually predicting all 75 projections which are 5 sets of 15 projections at 5 locations in FACET-II, but to save space we just show a few of the projections.
Furthermore, we emphasize that both the input beam distributions and the accelerator parameters in the test set were unseen during the CNN's training process and the CNN is now predicting the correct 2D phase space distributions without needing access to accurate input beam distributions or to accelerator parameters. This is the major strength of this approach which makes it robust to time-varying systems for which invasive input beam distributions are no longer available after an initial dedicated training period which might take place during a dedicated beam development time.

Conclusions
An adaptive latent space tuning method has been developed and demonstrated on FACET-II and HiRES based on encoder-decoder style CNNs whose generative halves predict various 2D phase space projections of charged particle beams based only on a single 2D phase space slice measurement such as the LPS provided by TCAVs. Unlike traditional ML-based methods this is robust to unknown time-varying input beam distributions which are represented by the low dimensional latent space of the CNN which is quickly and automatically adjusted based on model-independent feedback. cost Figure 9. Convergence in the 3D latent space is shown, which takes approximately 150 steps. We show all 3 2D projections as well as the evolution of the trajectory (black) in the full 3D latent space with the underlying test set-based latent space colored by the value of the cost function. LAB 20-2261, project "Leveraging ML/AI techniques to enable a breakthrough in ultra-short-bunch paradigm."