Deep learning for universal linear embeddings of nonlinear dynamics
Bethany Lusch J. Nathan Kutz Steven L. Brunton
math.DS cs.LG stat.ML

[NO \title GIVEN]
    [NO \author GIVEN]
    December 30, 2023
======================



^* Corresponding author (herwaldt@uw.edu).
 Code:  github.com/BethanyL/DeepKoopman







Identifying coordinate transformations that make strongly nonlinear dynamics approximately linear is a central challenge in modern dynamical systems.  

These transformations have the potential to enable prediction, estimation, and control of nonlinear systems using standard linear theory.   

The Koopman operator has emerged as a leading data-driven embedding, as eigenfunctions of this operator provide intrinsic coordinates that globally linearize the dynamics. 

However, identifying and representing these eigenfunctions has proven to be mathematically and computationally challenging.  

This work leverages the power of deep learning to discover representations of Koopman eigenfunctions from trajectory data of dynamical systems.  

Our network is parsimonious and interpretable by construction, embedding the dynamics on a low-dimensional manifold parameterized by these eigenfunctions.  

In particular, we identify nonlinear coordinates on which the dynamics are globally linear using a modified auto-encoder.  

We also generalize Koopman representations to include a ubiquitous class of systems that exhibit continuous spectra, ranging from the simple pendulum to nonlinear optics and broadband turbulence.  

Our framework parametrizes the continuous frequency using an auxiliary network, enabling a compact and efficient embedding, while connecting our models to half a century of asymptotics. 

In this way, we benefit from the power and generality of deep learning, while retaining the physical interpretability of Koopman embeddings. 



Keywords–
Dynamical systems, Koopman theory, machine learning, deep learning. 










§ INTRODUCTION

Nonlinearity is a hallmark feature of complex systems, giving rise to a rich diversity of observed dynamical behaviors across the physical, biological, and engineering sciences <cit.>.  

Although computationally tractable, there exists no general mathematical framework for solving nonlinear dynamical systems.

Thus representing nonlinear dynamics in a linear framework is particularly appealing because of powerful and comprehensive techniques for the analysis and control of linear systems <cit.>, which do not readily generalize to nonlinear systems.  

Koopman operator theory, developed in 1931 <cit.>, has recently emerged as a leading candidate for the systematic linear representation of nonlinear systems <cit.>.  

This renewed interest in Koopman analysis has been driven by a combination of theoretical advances <cit.>, improved numerical methods such as dynamic mode decomposition (DMD) <cit.>, and an increasing abundance of data.  

Eigenfunctions of the Koopman operator are now widely sought, as they provide intrinsic coordinates that globally linearize nonlinear dynamics.  

Despite the immense promise of Koopman embeddings, obtaining representations has proven difficult in all but the simplest systems, and representations are often intractably complex or are the output of uninterpretable black-box optimizations.  

In this work, we utilize the power of deep learning for flexible and general representations of the Koopman operator, while enforcing a network structure that promotes parsimony and interpretability of the resulting models.  


Neural networks (NNs), which form the theoretical architecture of deep learning, were inspired by the primary visual cortex of cats where neurons are organized in hierarchical layers of cells to process visual stimulus <cit.>.  

The first mathematical model of a NN was the neocognitron <cit.> which has many of the features of modern deep neural networks (DNNs), including a multi-layer structure, convolution, max pooling and nonlinear dynamical nodes.

Importantly, the universal approximation theorem <cit.> guarantees that a NN with sufficiently many hidden units and a linear output layer is capable of representing any arbitrary function, including our desired Koopman eigenfunctions.  

Although NNs have a four-decade history, the analysis of the ImageNet data set <cit.>, containing over 15 million labeled images in 22,000 categories, provided a watershed moment <cit.>.  

Indeed, powered by the rise of big data and increased computational power, deep learning is resulting in transformative progress in many data-driven classification and identification tasks <cit.>. 

A strength of deep learning is that features of the data are built hierarchically, which enables the representation of complex functions.

Thus, deep learning can accurately fit functions without hand-designed features or the user choosing a good basis <cit.>.

However, a current challenge in deep learning research is the identification of parsimonious, interpretable, and transferable models <cit.>. 







Deep learning has the potential to enable a scaleable and data-driven architecture for the discovery and representation of Koopman eigenfunctions, providing intrinsic linear representations of strongly nonlinear systems.  


This approach alleviates two key challenges in modern dynamical systems: 1) equations are often unknown for systems of interest <cit.>, as in climate, neuroscience, epidemiology, and finance; and, 2) low-dimensional dynamics are typically embedded in a high-dimensional state space, requiring scaleable architectures that discover dynamics on latent variables.  

Although NNs have also been used to model dynamical systems <cit.> and other physical processes <cit.> for decades, great strides have been made recently in using DNNs to learn Koopman embeddings, resulting in several excellent papers <cit.>.  

For example, the VAMPnet architecture <cit.> uses a time-lagged auto-encoder and a custom variational score to identify Koopman coordinates on an impressive protein folding example.  

In all of these recent studies, DNN representations have been shown to be more flexible and exhibit higher accuracy than other leading methods on challenging problems.  


The focus of this work is on developing DNN representations of Koopman eigenfunctions that remain interpretable and parsimonious, even for high-dimensional and strongly nonlinear systems.  

Our approach (See Fig. <ref>) differs from previous studies, as we are focused specifically on obtaining parsimonious models that match the intrinsic low-rank dynamics while avoiding overfitting and remaining interpretable, thus merging the best of DNN architectures and Koopman theory.  

In particular, many dynamical systems exhibit a continuous eigenvalue spectrum, which confounds low-dimensional representation using existing DNN or Koopman representations.  

This work develops a generalized framework and enforces new constraints specifically designed to extract the fewest meaningful eigenfunctions in an interpretable manner.  

For systems with continuous spectra, we utilize an augmented network to parameterize the linear dynamics on the intrinsic coordinates, avoiding an infinite asymptotic expansion in  harmonic eigenfunctions.  

Thus, the resulting networks remain parsimonious, and the few key eigenfunctions are interpretable.  

We demonstrate our deep learning approach to Koopman on several examples designed to illustrate the strength of the method, while remaining intuitive in terms of classic dynamical systems.  









§ DATA-DRIVEN DYNAMICAL SYSTEMS

To give context to our deep learning approach to identify Koopman eigenfunctions, we first summarize highlights and challenges in the data-driven discovery of dynamics.  
Throughout this work, we will consider discrete-time dynamical systems,


    𝐱_k+1 = 𝐅(𝐱_k),


where 𝐱∈ℝ^n is the state of the system and 𝐅 represents the dynamics that map the state of the system forward in time.   
Discrete-time dynamics often describe a continuous-time system that is sampled discretely in time, so that 𝐱_k=𝐱(kΔ t) with sampling time Δ t.  
The dynamics in 𝐅 are generally nonlinear, and the state 𝐱 may be high dimensional, although we typically assume that the dynamics evolve on a low-dimensional attractor governed by persistent coherent structures in the state space <cit.>.  

Note that 𝐅 is often unknown and only measurements of the dynamics are available.

The dominant geometric perspective of dynamical systems, in the tradition of Poincaré, concerns the organization of trajectories of Eq. <ref>, including fixed points, periodic orbits, and attractors. 
Formulating the dynamics as a system of differential equations in 𝐱 often admits compact and efficient representations for many natural systems <cit.>; for example, Newton's second law is naturally expressed by Eq. <ref>.  
However, the solution to these dynamics may be arbitrarily complicated, and possibly even irrepresentable, except for special classes of systems.  
Linear dynamics, where the map 𝐅 is a matrix that advances the state 𝐱, are among the few systems that admit a universal solution, in terms of the eigenvalues and eigenvectors of the matrix 𝐅, also known as the spectral expansion.   

 



 §.§ Koopman operator theory
 
In 1931, B. O. Koopman provided an alternative description of dynamical systems in terms of the evolution of functions in the Hilbert space of possible measurements y=g(𝐱) of the state <cit.>.  
The so-called Koopman operator, 𝒦, that advances measurement functions is an infinite-dimensional linear operator:

    𝒦 g≜ g∘𝐅  ⟹  𝒦g(𝐱_k) = g(𝐱_k+1).

Koopman analysis has gained significant attention recently with the pioneering work of Mezic et al. <cit.>, and in response to the growing wealth of measurement data and the lack of known equations for many systems <cit.>.  
Representing nonlinear dynamics in a linear framework, via the Koopman operator, has the potential to enable advanced nonlinear prediction, estimation, and control using the comprehensive theory developed for linear systems.  
However, obtaining finite-dimensional approximations of the infinite-dimensional Koopman operator has proven challenging in practical applications.  

Finite-dimensional representations of the Koopman operator are often approximated using the dynamic mode decomposition (DMD) <cit.>, introduced by Schmid <cit.>.  

By construction, DMD identifies spatio-temporal coherent structures from a high-dimensional dynamical system, although it does not generally capture nonlinear transients since it is based on linear measurements of the system, g(𝐱)=𝐱.  

Extended DMD (eDMD) and the related variational approach of conformation dynamics (VAC) <cit.> enriches the model with nonlinear measurements <cit.>; for more details, see SI Appendix.  

Identifying regression models based on nonlinear measurements will generally result in closure issues, as there is no guarantee that these measurements form a Koopman invariant subspace <cit.>.  

The resulting models are of exceedingly high dimension, and when kernel methods are employed <cit.>, the models may become uninterpretable.  

Instead, many approaches seek to identify eigenfunctions of the Koopman operator directly, satisfying:


    φ(𝐱_k+1) = 𝒦φ(𝐱_k) = λφ(𝐱_k).


Eigenfunctions are guaranteed to span an invariant subspace, and the Koopman operator will yield a matrix when restricted to this subspace <cit.>.  

In practice, Koopman eigenfunctions may be more difficult to obtain than the solution of (<ref>); however, this is a one-time up-front cost that yields a compact linear description. 

The challenge of identifying and representing Koopman eigenfunctions provides strong motivation for the use of powerful emerging deep learning methods <cit.>.  







 §.§ Koopman for systems with continuous spectra

The Koopman operator provides a global linearization of the dynamics.  

The concept of linearizing dynamics is not new, and locally linear representations are commonly obtained by linearizing around fixed points and periodic orbits <cit.>.  

Indeed, asymptotic and perturbation methods have been widely used since the time of Newton to approximate solutions of nonlinear problems by starting from the exact solution of a related, typically linear problem.  

The classic pendulum, for instance, satisfies the differential equation ẍ = -sin(ω x) and has eluded an analytic solution since its mathematical inception.

The linear problem associated with the pendulum involves the small angle approximation whereby sin(ω x) = ω x - (ω x)^3/3! + ⋯ and only the first term is retained in order to yield exact sinusoidal solutions.  

The next correction involving the cubic term gives the Duffing equation which is one of the most commonly studied nonlinear oscillators in physics <cit.>.    

Importantly, the cubic contribution is known to shift the linear oscillation frequency of the pendulum, ω→ω+Δω as well as generate harmonics such as exp(± 3i ω) <cit.>.

An exact representation of the solution can be derived in terms of Jacobi elliptic functions, which have a Taylor series representation in terms of an infinite sum of sinusoids with frequencies (2n-1)ω where n=1, 2, ⋯, ∞.

Thus, the simple pendulum oscillates at the (linear) natural frequency ω for small deflections, and as the pendulum energy is increased, the frequency decreases continuously, resulting in a so-called continuous spectrum.  

The importance of accounting for the continuous spectrum was discussed in 1932 in an extension by Koopman and von Neumann <cit.>.    

A continuous spectrum, as described for the simple pendulum, is characterized by a continuous range of observed frequencies, as opposed to the discrete spectrum consisting of isolated, fixed  frequencies.  

This phenomena is observed in a wide range of physical systems that exhibit broadband frequency content, such as turbulence and nonlinear optics.  

The continuous spectrum thus confounds simple Koopman descriptions, as there is not a straightforward finite approximation in terms of a small number of eigenfunctions <cit.>.  

Indeed, away from the linear regime, an infinite Fourier sum is required to approximate the shift in frequency and eigenfunctions.

In fact, in some cases, eigenfunctions may not exist at all.   


Recently, there have been several algorithmic advances to approximate systems with continuous spectra, including nonlinear Laplacian spectral analysis <cit.> and the use of delay coordinates <cit.>.  

A critically enabling innovation of the present work is explicitly accounting for the parametric dependence of the Koopman operator K(λ) on the continuously varying λ, related to the classic perturbation results above.   

By constructing an auxiliary network (See Fig. <ref>) to first determine the parametric dependency of the Koopman operator on the frequency λ_±=± iω, an interpretable low-rank model of the intrinsic dynamics can then by constructed.  

In particular, a nonlinear oscillator with continuous spectrum may now be represented as a single pair of conjugate eigenfunctions, mapping trajectories into perfect sines and cosines, with a continuous eigenvalue parameterizing the frequency.  

If this explicit frequency dependence is unaccounted for, then a high-dimensional network is necessary to account for the shifting frequency and eigenvalues.  

We conjecture that previous Koopman models using high-dimensional DNNs represent the harmonic series expansion required to approximate the continuous spectrum for systems such as the Duffing oscillator.










§ DEEP LEARNING TO IDENTIFY KOOPMAN EIGENFUNCTIONS

The overarching goal of this work is to leverage the power of deep learning to discover and represent eigenfunctions of the Koopman operator.  

Our perspective is driven by the need for parsimonious representations that are efficient, avoid overfitting, and provide minimal descriptions of the dynamics on interpretable intrinsic coordinates.  

Unlike previous deep learning approaches to Koopman <cit.>, our network architecture is designed specifically to handle a ubiquitous class of nonlinear systems characterized by a continuous frequency spectrum generated by the nonlinearity.  

A continuous spectrum presents unique challenges for compact and interpretable representation, and our approach is inspired by the classical asymptotic and perturbation approaches in dynamical systems.  

Our core network architecture is shown in Fig. <ref>, and it is modified in Fig. <ref> to handle the continuous spectrum. 

The objective of this network is to identify a few key intrinsic coordinates 𝐲 = φ(𝐱) spanned by a set of Koopman eigenfunctions φ:ℝ^n→ℝ^p, along with a dynamical system 𝐲_k+1 = 𝐊𝐲_k.  

There are three high-level requirements for the network, corresponding to three types of loss functions used in training:



  * Intrinsic coordinates that are useful for reconstruction. We seek to identify a few intrinsic coordinates 𝐲 = φ(𝐱) where the dynamics evolve, along with an inverse 𝐱 = φ^-1(𝐲) so that the state 𝐱 may be recovered.  This is achieved using an auto-encoder (See Figure <ref> a.), where φ is the encoder and φ^-1 is the decoder.  The dimension p of the auto-encoder subspace is a hyperparameter of the network, and this choice may be guided by knowledge of the system.  Reconstruction accuracy of the auto-encoder is achieved using the following loss: 𝐱 - φ^-1 (φ(𝐱)).  


  * Linear dynamics. To discover Koopman eigenfunctions, we learn the linear dynamics 𝐊 on the intrinsic coordinates, i.e., 𝐲_k+1=  K𝐲_k.  Linear dynamics are achieved using the following loss: φ(𝐱_k+1) -  Kφ(𝐱_k).  More generally, we enforce linear prediction over m time steps with the loss: φ(𝐱_k+m) -   K^m φ(𝐱_k).  (See Figure <ref> c.) 



  * Future state prediction. Finally, the intrinsic coordinates must enable future state prediction.  Specifically, we identify linear dynamics in the matrix 𝐊.  This corresponds to the loss 𝐱_k+1 - φ^-1 ( Kφ(𝐱_k)), and more generally 𝐱_k+m - φ^-1 ( K^m φ(𝐱_k)). 
 (See Figure <ref> b.) 

  
Our norm · is mean-squared error, averaging over dimension then number of examples, and we add ℓ_2 regularization.

To address the continuous spectrum, we allow the eigenvalues of the matrix K to vary, parametrized by the function λ=Λ(𝐲), which is learned by an auxiliary network (See Fig. <ref>). The eigenvalues λ_±=μ± iω are then used to parametrize block-diagonal K(μ, ω). For each pair of complex eigenvalues, the discrete-time K has a Jordan block of the form:


    B(μ, ω) = exp(μΔ t)
    [  cos(ωΔ t) -sin(ωΔ t);  sin(ωΔ t)  cos(ωΔ t) ].

This network structure allows the eigenvalues to vary across phase space, facilitating a small number of eigenfunctions.   
To enforce circular symmetry in the eigenfunction coordinates, we often parameterize the eigenvalues by the radius λ(𝐲_2^2).  
The second and third prediction loss function must also be modified for systems with continuous spectrum, as discussed in the SI Appendix.  


To train our network, we generate trajectories from random initial conditions, which are split into training, validation, and test sets. 

Models are trained on the training set and compared on the validation set, which is also used for early stopping to prevent overfitting.  

We report accuracy on the test set. 






§ RESULTS

We demonstrate our deep learning approach to identify Koopman eigenfunctions on several example systems, including a simple model with a discrete spectrum and two examples that exhibit a continuous spectrum:  the nonlinear pendulum and the high-dimensional unsteady fluid flow past a cylinder.  






 §.§ Simple model with discrete spectrum

Before analyzing systems with the additional challenges of a continuous spectrum and high-dimensionality, we consider a simple nonlinear system with a single fixed point and a discrete eigenvalue spectrum:


    ẋ_1    = μ x_1
    ẋ_2     = λ (x_2-x_1^2).


This dynamical system has been well-studied in the literature <cit.>, and for stable eigenvalues λ < μ < 0, the system exhibits a slow manifold given by x_2=x_1^2; we use μ=-0.05 and λ=-1.  
As shown in Fig. <ref>, the Koopman embedding identifies nonlinear coordinates that flatten this inertial manifold, providing a globally linear representation of the dynamics; moreover, the correct Koopman eigenvalues are identified.  
Specific details about the network and training procedure are provided in the SI Appendix.  









 §.§ Nonlinear pendulum with continuous spectrum

As a second example, we consider the nonlinear pendulum, which exhibits a continuous eigenvalue spectrum with increasing energy:


    ẍ=-sin(x)  ⟹  {[         ẋ_1 = x_2;                   ẋ_2  = -sin(x_1). ].


Although this is a simple mechanical system, it has eluded parsimonious representation in the Koopman framework.  
The deep Koopman embedding is shown in Fig. <ref>, where it is clear that the dynamics are linear in the eigenfunction coordinates, given by 𝐲=φ(𝐱).    
As the Hamiltonian energy of the system increases, corresponding to an elongation of the oscillation period, the parameterized Koopman network accounts for this continuous frequency shift and provides a compact representation in terms of two conjugate eigenfunctions.  
Alternative network architectures that are not specifically designed to account for continuous spectra with an auxiliary network would be forced to approximate this frequency shift with the classical asymptotic expansion in terms of harmonics.  
The resulting network would be overly bulky and would limit interpretability.  

Recall that we have three types of losses on the network: reconstruction, prediction, and linearity. 
Figure <ref>II.A shows that the network is able to function as an auto-encoder, accurately reconstructing the ten example trajectories. 
Next, we show that the network is able to predict the evolution of the system.  
Figure <ref>II.B shows the prediction horizon for ten initial conditions that are simulated forward with the network, stopping the prediction when the relative error reaches 10%.  
As expected, the prediction horizon deteriorates as the energy of the initial condition increases, although the prediction is still quite accurate.  
Finally, we demonstrate that the dynamics in the intrinsic coordinates 𝐲 are truly linear, as shown by the nearly concentric circles in Fig. <ref>II.C.  
The eigenfunctions φ_1(𝐱) and φ_2(𝐱) are shown in Fig. <ref>III, and are connected to theory <cit.> in the SI Appendix. 



 §.§ High-dimensional nonlinear fluid flow

As our final example, we consider the nonlinear fluid flow past a circular cylinder at Reynolds number 100 based on diameter, which is characterized by vortex shedding.  
This model has been a benchmark in fluid dynamics for decades <cit.>, and has been extensively analyzed in the context of data-driven modeling <cit.> and Koopman analysis <cit.>.  
In 2003, Noack et al. <cit.> showed that the high-dimensional dynamics evolve on a low-dimensional attractor, given by a slow-manifold in the following model: 


    ẋ_1    = μ x_1 - ω x_2 + A x_1x_3
    ẋ_2    = ω x_1 + μ x_2 + A x_2x_3
    ẋ_3     = -λ (x_3-x_1^2-x_2^2).


This mean-field model exhibits a stable limit cycle corresponding to von Karman vortex shedding, and an unstable equilibrium corresponding to a low-drag condition.  
Starting near this equilibrium, the flow unwinds up the slow manifold toward the limit cycle.  

In <cit.>, Loiseau showed that this flow may be modeled by a nonlinear oscillator with state-dependent damping, making it amenable to the continuous spectrum analysis.  
We use trajectories from this model to train a Koopman network, and the resulting eigenfunctions are shown in Fig. <ref>. 

In this example, the damping rate μ and frequency ω are allowed to vary along level sets of the radius in eigenfunction coordinates, so that μ(R) and ω(R), where R^2=y_1^2+y_2^2; this is accomplished with an auxiliary network as in Fig. <ref>.  
Although we only show the ability of the model to predict the future state in Fig. <ref>, corresponding to the second and third loss functions, the network also functions as an autoencoder.  






§ DISCUSSION

In summary, we have employed powerful deep learning approaches to identify and represent coordinate transformations that recast strongly nonlinear dynamics into a globally linear framework.  

Our approach is designed to discover eigenfunctions of the Koopman operator, which provide an intrinsic coordinate system to linearize nonlinear systems, and have been notoriously difficult to identify and represent using alternative methods.  

Building on a deep auto-encoder framework, we enforce additional constraints and loss functions to identify Koopman eigenfunctions where the dynamics evolve linearly.  

Moreover, we generalize this framework to include a broad class of nonlinear systems that exhibit a continuous eigenvalue spectrum, where a continuous range of frequencies is observed.  

Continuous-spectrum systems are notoriously difficult to analyze, especially with Koopman theory, and naive learning approaches require asymptotic expansions in terms of higher order harmonics of the fundamental frequency, leading to unwieldy models.

In contrast, we utilize an auxiliary network to parametrize and identify the continuous frequency, which then parameterizes a compact Koopman model on the auto-encoder coordinates.   

Thus, our deep neural network models remain both parsimonious and interpretable, merging the best of neural network representations and Koopman embeddings.  

In most deep learning applications, although the basic architecture is extremely general, considerable expert knowledge and intuition is typically used in the training process and in designing loss functions and constraints.  

Throughout this paper, we have also used physical insight and intuition from asymptotic theory and continuous spectrum dynamical systems to design parsimonious Koopman embeddings.  


The use of deep learning in physics and engineering is increasing at an incredible rate, and this trend is only expected to accelerate.  

Nearly every field of science is revisiting challenging problems of central importance from the perspective of big data and deep learning.

With this explosion of interest, it is imperative that we as a community seek machine learning models that favor interpretability and promote physical insight and intuition.  

In this challenge, there is a tremendous opportunity to gain new understanding and insight by applying increasingly powerful techniques to data. 

For example, discovering Koopman eigenfunctions will result in new symmetries and conservation laws, as conserved eigenfunctions are related to conservation laws via a generalized Noether's theorem.  

It will also be important to apply these techniques to increasingly challenging problems, such as turbulence, epidemiology, and neuroscience, where data is abundant and models are needed.  

The goal is to model these systems with a small number of coupled nonlinear oscillators using similar parameterized Koopman embeddings.  

Finally, the use of deep learning to discover Koopman eigenfunctions may enable transformative advances in the nonlinear control of complex systems.  

All of these future directions will be facilitated by more powerful network representations.  



§ ACKNOWLEDGEMENTS
 
We acknowledge generous funding from the Army Research Office (ARO W911NF-17-1-0306) and the Defense Advanced Research Projects Agency (DARPA HR0011-16-C-0016).  We would like to thank many people for valuable discussions  about neural networks and Koopman theory:  Bing Brunton, Karthik Duraisamy, Eurika Kaiser, Bernd Noack, and Josh Proctor, and especially Jean-Christophe Loiseau, Igor Mezić, and Frank Noé.




plain






§ SUPPORTING INFORMATION (SI)



 §.§ Model problems and training datasets

We demonstrate the ability of deep learning to represent Koopman eigenfunctions on three example systems, shown in Fig. <ref>. 


The first system has a single fixed point and a discrete eigenvalue spectrum:



    ẋ_1    = μ x_1
    ẋ_2     = λ (x_2-x_1^2),



where μ = -0.05 and λ = -1. This provides a benchmark system to test our architecture.

The second system is the nonlinear pendulum:



    ẋ_1    = x_2
    ẋ_2    = -sin(x_1).



The nonlinear pendulum exhibits a continuous eigenvalue spectrum as the energy of the pendulum is increased, posing a significant challenge for classical Koopman embedding techniques.  
In this example, we consider the frictionless pendulum, so that the system is conservative and trajectories evolve on Hamiltonian energy level sets. 

The third example is the mean-field model <cit.> for the fluid flow past a circular cylinder at Reynolds number 100:



    ẋ_1    = μ x_1 - ω x_2 + A x_1x_3
    ẋ_2    = ω x_1 + μ x_2 + A x_2x_3
    ẋ_3     = -λ (x_3-x_1^2-x_2^2),



where μ = 0.1, ω = 1, A = -0.1, and λ = 10. This system is a challenging canonical system in fluid dynamics, and is a model for the vortex shedding observed behind bluff bodies.  The system exhibits a slow manifold, and we consider two cases corresponding to trajectories that start on the slow manifold and trajectories that start off of the manifold.  





  §.§.§ Creating the datasets

We create our datasets by solving the systems of differential equations in MATLAB using the  solver.

For each dynamical system, we choose 5000 initial conditions for the test set, 5000 for the validation set, and 5000-20000 for the training set (see Table <ref>). For each initial condition, we solve the differential equations for some time span. That time span is t = 0, .02, …, 1 for the discrete spectrum and pendulum datasets. Since the dynamics on the slow manifold for the fluid flow example are slower and more complicated, we increase the time span for that dataset to t = 0, .05, …, 6. However, when we include data off the slow manifold, we want to capture the fast dynamics as the trajectories are attracted to the slow manifold, so we change the time span to t = 0, .01, …, 1.

The discrete spectrum dataset is created from random initial conditions 𝐱 where x_1, x_2 ∈ [-0.5, 0.5], since this portion of phase space is sufficient to capture the dynamics. 

The pendulum dataset is created from random initial conditions 𝐱 where x_1 ∈ [-3.1, 3.1] (just under [-π, π]), x_2 ∈ [-2, 2], and the potential function is under 0.99. The potential function for the pendulum is 1/2x_2^2 - cos(x_1). These ranges are chosen to sample the pendulum in the full phase space where the pendulum approaches having an infinite period.



The fluid flow problem limited to the slow manifold is created from random initial conditions 𝐱 on the bowl where r ∈ [0, 1.1], θ∈ [0, 2π], x_1 = rcos(θ), x_2 = rsin(θ), and x_3 = x_1^2 + x_2^2. This captures all types of dynamics on the slow manifold, including spiraling in towards the limit cycle at r=1 and spiraling out towards it. 

The fluid flow problem beyond the slow manifold is created from random initial conditions 𝐱 where x_1 ∈ [-1.1, 1.1], x_2 ∈ [-1.1, 1.1], and x_3 ∈ [0, 2.42]. These limits are chosen to include the dynamics on the slow manifold covered by the previous dataset, as well as trajectories that begin off the slow manifold.  Any trajectory that grows to x_3 > 2.5 is eliminated so that the domain is reasonably compact and well-sampled. 






 §.§ Network architecture and training




  §.§.§ Code

We use the Python API for the TensorFlow framework <cit.> and the Adam optimizer <cit.> for training. All of our code is available online at <github.com/BethanyL/DeepKoopman>. 



  §.§.§ Network architecture

Each hidden layer has the form of W𝐱 + b followed by an activation with the rectified linear unit (ReLU): f(𝐱) = max{0, 𝐱}. In our experiments, training was significantly faster with ReLU as the activation function than with sigmoid.  See Table <ref> for the number of hidden layers in the encoder, decoder, and auxiliary network, as well as their widths. The output layers of the encoder, decoder, and auxiliary network are linear (simply W𝐱 + b).

The input to the auxiliary network is y, and it outputs the parameters for the eigenvalues of K. 

For each complex conjugate pair of eigenvalues λ_± = μ± i ω, the network defines a function Λ mapping y_j^2 + y_j+1^2 to μ and ω, where y_j and y_j+1 are the corresponding eigenfunctions. 

Similarly, for each real eigenvalue λ, the network defines a function mapping y_j to λ. 

For example, for the fluid flow problem off the attractor, we have three eigenfunctions. 

The auxiliary network learns a map from y_1^2 + y_2^2 to μ and ω and another map from y_3 to λ. 

This could be implemented as one network defining a mapping Λ: ℝ^2 →ℝ^3 where the layers are not fully connected (y_1^2 + y_2^2 should not influence λ and y_3 should not influence μ and ω). 

However, for simplicity, we implement this as two separate auxiliary networks, one for the complex conjugate pair of eigenvalues and one for the the real eigenvalue.





  §.§.§ Explicit loss function

Our loss function has three weighted mean-squared error components: reconstruction accuracy ℒ_recon, future state prediction ℒ_pred, and linearity of dynamics ℒ_lin. 

Since we know that there are no outliers in our data, we also use an ℒ_∞ term to penalize the data point with the largest loss. 

Finally, we add ℓ_2 regularization on the weights W to avoid overfitting.

More specifically: 



    ℒ   = α_1 (ℒ_recon + ℒ_pred) + ℒ_lin + α_2 ℒ_∞ + α_3 W^2_2
    ℒ_recon   = 𝐱_1 - φ^-1 (φ(𝐱_1)) _MSE
    
    ℒ_pred    = 1/S_p∑_m=1^S_p𝐱_m+1 - φ^-1 ( K^m φ(𝐱_1))_MSE
    
    ℒ_lin    = 1/T-1∑_m=1^T-1φ(𝐱_m+1) -   K^m φ(𝐱_1)_MSE
    
    ℒ_∞    = 𝐱_1 - φ^-1 (φ(𝐱_1)) _∞ + 𝐱_2 - φ^-1 ( Kφ(𝐱_1))_∞,


where MSE refers to mean squared error and T is the number of time steps in each trajectory. 

The weights α_1, α_2, and α_3 are hyperparameters.

The integer S_p is a hyperparameter for how many steps to check in the prediction loss.

The hyperparameters α_1, α_2, α_3, and S_p are listed in Table <ref>.




The matrix K is parametrized by the function λ=Λ(𝐲), which is learned by an auxiliary network. 

The eigenvalues can vary along a trajectory, so in ℒ_pred and ℒ_lin, K^m =   K(λ_1) ·  K(λ_2) ⋯  K(λ_m). 

However, on Hamiltonian systems, such as the pendulum, the eigenvalues are constant along each trajectory. 

If a system is known to be Hamiltonian, the network training could be sped up by encoding the constraint that K^m =   K(λ)^m. 

In order to demonstrate that this specialized knowledge is not necessary, we use the more general case for all of our datasets, including the pendulum. 



  §.§.§ Training

We initialize each weight matrix W randomly from a uniform distribution in the range [-s, s] for s = 1/√(a), where a is the dimension of the input of the layer. This distribution was suggested in <cit.>. Each bias vector b is initialized to 0.  The model for the discrete spectrum example is trained for two hours on an NVIDIA K80 GPU. The other models are each trained for six hours. The learning rate for the Adam optimizer is 0.001. On the pendulum and fluid flow datasets, for five minutes, we pretrain the network to be a simple autoencoder, using the autoencoder loss but not the linearity or prediction losses, as this speeds up the training. For each dynamical system, we train multiple models in a random search of parameter space and choose the one with the lowest validation error. Each model is initialized with different random weights. We also use early stopping; for each model, at the end of training, we resume the step with the lowest validation error. 



 §.§ Results

The training, validation, and test errors for all examples are reported in Table <ref>.




  §.§.§ Discrete spectrum example

Figure <ref> shows the average prediction error versus the number of prediction steps.  Even for a large number of steps, the error is quite small, giving good prediction.  This figure also demonstrates prediction performance on example trajectories. 
The eigenfunctions for this example are shown in Fig. <ref>. We see that one is quadratic and the other is linear. This is expected because we can analytically derive that y_1 = x_1 and y_2 = x_2 - bx_1^2 is a pair of eigenfunctions for this system, where b = -λ/2μ - λ.
When the eigenvalues are allowed to vary with the auxiliary network used for continuous spectrum systems, the eigenvalues remain relatively constant, near the true values of -0.05 and -1, as shown in Fig. <ref>.  








  §.§.§ Nonlinear pendulum

The nonlinear pendulum is one of the simplest examples that exhibits a continuous eigenvalue spectrum.  
Using the auxiliary network, we allow the frequency ω of the Koopman eigenvalues to vary continuously with the embedded coordinates y_1 and y_2, as shown in Fig. <ref>.
The frequency ω varies smoothly with the radius √(y_1^2+y_2^2), from around -0.95 to -0.4 as the energy is increased.  
When the damping rate is also allowed to vary continuously, it remains nearly constant around the value of μ=0, since the system is conservative.  
Figure <ref> shows the Koopman eigenfunctions in magnitude and phase coordinates, where it can be seen that that magnitude essentially traces level sets of the Hamiltonian energy.  
This is consistent with previous theoretical derivations of Mezic <cit.>, and we thank him for communicating this connection to us.  







  §.§.§ Fluid flow on attractor

For the final example, we consider the nonlinear fluid vortex shedding behind a cylinder.  We begin by considering dynamics on the attracting manifold.  
When we train the network with trajectories on the slow manifold, we are able to identify a single conjugate eigenfunction pair, shown in Fig. <ref>.  
The corresponding continuously varying eigenvalues are shown in Fig. <ref>, where it can be seen that the frequency ω is extremely close to the true constant -1, while the damping μ varies significantly, and in fact switches stability for trajectories outside the natural limit cycle.  
This is consistent with the data-driven model of Loiseau <cit.>.  





  §.§.§ Fluid flow off attractor

We now consider the case where we train a network using trajectories that start off of the attracting slow manifold.  
Figure <ref> shows the prediction performance of the Koopman neural network for trajectories that start away from the bowl; in both cases, the dynamics are faithfully captured and the dynamics are propagated forward until the limit cycle.  


The eigenfunctions are shown in Fig. <ref>, where it can be seen that the mode shapes match those in the on-attractor data in Fig. <ref>.  
The continuously varying eigenvalues are shown in Fig. <ref>.  
Again, similar to the on-attractor case, the damping μ varies considerably with radius, while the frequency is very nearly a constant -1.  








 §.§ Miscellaneous notes



  §.§.§ Connection between eDMD and VAC

It has recently been shown that eDMD is equivalent to the variational approach of conformation dynamics (VAC) <cit.>, first derived by Noé and Nüske in 2013 to simulate molecular dynamics with a broad separation of timescales.  

Further connections between eDMD and VAC and between DMD and the time lagged independent component analysis (TICA) are explored in a recent review <cit.>.  

A key contribution of VAC is a variational score enabling the objective assessment of Koopman models via cross-validation.   

Recently, eDMD has been demonstrated to improve model predictive control performance in nonlinear systems <cit.>.

