Synthesis of Data-Driven Nonlinear State Observers using
  Lipschitz-Bounded Neural Networks
This paper focuses on the model-free synthesis of state observers for
nonlinear autonomous systems without knowing the governing equations.
Specifically, the Kazantzis-Kravaris/Luenberger (KKL) observer structure is
leveraged, where the outputs are fed into a linear time-invariant (LTI) system
to obtain the observer states, which can be viewed as the states nonlinearly
transformed by an immersion mapping, and a neural network is used to
approximate the inverse of the nonlinear immersion and estimate the states. In
view of the possible existence of noises in output measurements, this work
proposes to impose an upper bound on the Lipschitz constant of the neural
network for robust and safe observation. A relation that bounds the
generalization loss of state observation according to the Lipschitz constant,
as well as the $H_2$-norm of the LTI part in the KKL observer, is established,
thus reducing the model-free observer synthesis problem to that of
Lipschitz-bounded neural network training, for which a direct parameterization
technique is used. The proposed approach is demonstrated on a chaotic Lorenz
system.
Wentao Tang
# Synthesis of Data-Driven Nonlinear State Observers using Lipschitz-Bounded Neural Networks

###### Abstract

This paper focuses on the _model-free_ synthesis of state observers for nonlinear autonomous systems without knowing the governing equations. Specifically, the Kazantzis-Kravaris/Luenberger (KKL) observer structure is leveraged, where the outputs are fed into a linear time-invariant (LTI) system to obtain the observer states, which can be viewed as the states nonlinearly transformed by an immersion mapping, and a neural network is used to approximate the inverse of the nonlinear immersion and estimate the states. In view of the possible existence of noises in output measurements, this work proposes to impose an upper bound on the Lipschitz constant of the neural network for robust and safe observation. A relation that bounds the generalization loss of state observation according to the Lipschitz constant, as well as the \(H_{2}\)-norm of the LTI part in the KKL observer, is established, thus reducing the model-free observer synthesis problem to that of Lipschitz-bounded neural network training, for which a direct parameterization technique is used. The proposed approach is demonstrated on a chaotic Lorenz system.

## I Introduction

For nonlinear systems that arise from realistic engineering applications such as transport-reaction processes, modern control theory relies on _state-space representations_ for their modeling, analysis, and control [1, 2, 3]. Recent advances in nonlinear control have highlighted the role of data-driven (machine learning) techniques in identifying governing equations or underlying dynamical structures [4, 5, 6], analyzing system and control-theoretic properties [7, 8], and synthesizing model-free controllers [9, 10, 11]. In these efforts, it is often assumed that the _state_ information is available for analysis or control; for example, in reinforcement learning (RL) literature, it is common to apply stochastic first-order optimization to learn a value (cost) function or \(Q\) function based on temporal actions and state measurements. In many (if not most) control engineering applications, such as in chemical processes, however, it is more likely that the states are not measurable.

Hence, for nonlinear control in a state-space framework, a _state observer_ is necessary, whereby the states are estimated based on input and output history [12]. A recent review on model-based approaches to synthesize state observers is found in Bernard, Andrieu, and Astolfi [13]. A classical form of state observer for linear systems is known as Luenberger observer [14], which an auxiliary linear time-invariant (LTI) system that uses the plant outputs as inputs and returns state estimates. The observer states are in fact a linear transform of the plant states [15]. The idea was extended to nonlinear systems in the seminal work of Kazantzis and Kravaris [16]. In their Kazantzis-Kravaris/Luenberger (KKL) observer (as named in Andrieu and Praly [17]) still uses an LTI system to convert plant outputs to observer states, which turn out to be the plant states transformed via a nonlinear immersion. Thus, the observer synthesis problem reduces to the determination of this nonlinear immersion and its inverse, via solving (model-based) partial differential equations (PDEs). Such a KKL observer was extended from autonomous to actuated systems in [18], where the LTI part is replaced by an input-affine one with an additional nonlinear drift term associated with the actuated inputs.

This paper focuses on the _synthesis of KKL observer_ in a _model-free_ manner, without assuming prior knowledge on the plant dynamics. This is motivated by two reasons: (i) many nonlinear systems that involve complex kinetic or kinematic mechanisms are often hard to model accurately, and (ii) it can be challenging to solve the associated PDEs, especially in high-dimensional state space (in fact, there may not be well-posed boundary conditions). In the recent years, there have been several works that pioneered the use of neural networks in the observer problem. For example, Ramos et al. [19] first trained neural networks to approximate the inverse immersion map to reconstruct the actual states from observer states. Then, the optimization of pole placement was considered along with the training of inverse immersion in [20]. Niazi et al. [21] used physics-informed neural networks (PINNs) to approach a surrogate solution to solve the PDEs. Miao and Gatsis [22] formulated a dynamic optimization problem to minimize the accumulated squared state observation error, whereby the optimality condition, through calculus of variations results in neural ODEs.

It is commonly known that neural networks, when over-parameterized with large widths and depths, may cause a deteriorated capability of generalization. It has also been argued that neural networks can be fragile to adversarial attacks to the training data and thus must be equipped with a self-defense mechanisms that warranty robustness [23, 24]. In particular, controlling the Lipschitz constant of the mapping specified by the neural network has been studied as a promising approach [25, 26, 27]. However, in these works, estimating and minimizing the Lipschitz constant requires the use of semidefinite programming routines, which has a high complexity when the number of neurons is large. An alternative way, called _direct paramterizaton_, as recently proposed in Wang and Manchester [28], is to translate the Lipschitz bound constraint into a special architecture of
the neural layers, thus allowing the use of typical back-propagation (BP) to train the network in an unconstrained way.

Hence, in this work, the Wang-Manchester direct parameterization is adopted to train Lipschitz-bounded neural networks in a KKL state observer for any unknown nonlinear autonomous system. The paper establishes a relation between the generalized observation error and the Lipschitz bound of the neural network as well as the \(H_{2}\)-norm of the LTI observer dynamics, under a typical white noise assumption on the plant outputs. Hence, by varying the Lipschitz bound, the optimal observer can be synthesized.

## II Preliminaries

We consider a nonlinear autonomous system:

\[\dot{x}(t)=f(x(t)),\quad y(t)=h(x(t)) \tag{1}\]

where \(x(t)\in\mathcal{X}\subseteq\mathbb{R}^{n}\) is the vector of states and \(y(t)\in\mathbb{R}^{m}\) represents the outputs. For simplicity, we will consider \(m=1\). It is assumed that \(f\) and \(h\) are smooth on \(\mathcal{X}\) to guarantee existence and uniqueness of solution but unknown for model-based synthesis.

### _KKL Observer_

For nonlinear systems, KKL observer generalizes the notion of Luenberger observers that were restricted to linear systems [14], providing a generic method for state observation with mild assumptions to guarantee existence. Specifically, the KKL observer for (1) is expressed as

\[\dot{z}(t)=Az(t)+By(t),\quad\hat{x}(t)=T^{\dagger}(z(t)). \tag{2}\]

Here the observer states \(z\in\mathbb{R}^{n_{z}}\) has an LTI dynamics. The matrices \(A\) and \(B\) are chosen under the requirements of (i) controllability of \((A,B)\) should be controllable, (ii) Hurwitz property of \(A\), and (iii) sufficiently high dimension of \(z\) (\(n_{z}\)), which should be at least \(n+1\) if \((A,B)\) is complex [17] and at least \(2n+1\) if \((A,B)\) is real [29]. The mapping from the observer states \(z\) to the state estimates \(\hat{x}\) is a static one, \(T^{\dagger}\), which is the left-pseudoinverse of a nonlinear immersion \(T\) (i.e., a differentiable injection satisfying \(T^{\dagger}\circ T=\mathsf{id}\)). This immersion \(T\) should satisfy the following PDE:

\[\frac{\partial T}{\partial x}(x)f(x)=AT(x)+Bh(x),\quad\forall x\in\mathcal{X}, \tag{3}\]

where \(\partial T/\partial x\) denotes the Jacobian matrix of \(T\). It can be easily verified that under the above PDE, \(dT(x)/dt=AT(x)+By\), and thus \(z-T(x)\) has an exponentially decaying dynamics, as \(A\) is Hurwitz.

The conditions for the existence of a KKL observer, namely the solution to its defining PDE (3), have been established based on the condition of backward distinguishability. In below, we denote the solution to the ODEs \(\dot{x}=f(x)\) at time \(t\) with initial condition \(x(0)=\xi\) as \(\Phi_{t}(\xi)\). For any open set \(\mathcal{O}\) in \(\mathcal{X}\), denote the backward time instant after which the solution does not escape this region by \(\varsigma_{\mathcal{O}}(\xi)=\inf\{t|\Phi_{t}(\xi)\in\mathcal{O}\}\). Also denote \(\mathcal{O}+\epsilon:=\{\xi+\eta|\xi\in\mathcal{O},\|\eta\|<\epsilon\}\).

**Definition 1** (Backward distinguishability).: _The system (1) is \((\mathcal{O},\epsilon)\)-backward distinguishable if for any distinct \(\xi,\xi^{\prime}\in\mathcal{X}\) there exists a negative \(t>\varsigma_{\mathcal{O}+\epsilon}(\xi)\wedge\varsigma_{\mathcal{O}+\epsilon} (\xi^{\prime})\) such that \(h(\Phi_{t}(\xi))\neq h(\Phi_{t}(\xi^{\prime}))\)._

**Fact 1** (Existence of KKL observer, cf. Brivadis et al. [29]).: _Assume that there is an open \(\mathcal{O}\subseteq\bar{\mathcal{X}}\) and a positive constant \(\epsilon\) such that the system (1) is \((\mathcal{O},\epsilon)\)-backward distinguishable. Then there exists a constant \(\rho>0\) such that for all but a Lebesgue-zero-measure set of \((A,B)\in\mathbb{R}^{(2n+1)\times(2n+1)}\times\mathbb{R}^{(2n+1)}\), if \(A+\rho I\) Hurwitz, then there exists an immersion \(T:\mathcal{O}\rightarrow\mathbb{R}^{(2n+1)}\) solving the PDEs (3)._

The above theorem clarifies that as long as the spectrum of \(A\) is restricted to the left of \(-\rho+i\mathbb{R}\), the LTI dynamics in the KKL observer can be almost arbitrarily assigned. Once \((A,B)\) are chosen, the remaining question for synthesis a KKL observer (2) is to numerically determine the solution. In view of the computational challenge in directly solving the PDEs (3) and the recent trend of handling the problem by neural approaches [19, 20, 21], this work will seek to approximate \(T^{\dagger}\) by a neural network. Yet, instead of using a vanilla multi-layer perceptron architecture, a Lipschitz-bounded neural network will be adopted, which safeguards the generalization performance of state observation, which will be discussed in SSIII. This overall idea is illustrated in Fig. 1.

### _Lipschitz-Bounded Neural Networks_

Consider a \(\nu\)-layer neural network \(\hat{x}=S(z,\theta)\) with all parameters denoted as a single vector \(\theta\). Without loss of generality, assume that the activation function (element-wise applied to vectors) is \(\sigma:\mathbb{R}\rightarrow\mathbb{R}\), with slope bounded in \([0,1]\) (in this work, rectified linear units (ReLU) are used to prevent gradient decay in BP training). The neural network then can be expressed as

\[\begin{split}& z^{\ell+1}=\sigma(W^{\ell}z^{\ell}+b^{\ell}),\ \ \ell=0,\ldots,\nu-1\\ & z^{0}=z,\quad\hat{x}=W^{\nu}z^{\nu}+b^{\nu}.\end{split} \tag{4}\]

where \(W^{0},\ldots,W^{\nu}\) are the weight matrices and \(b^{0},\ldots,b^{\nu}\) are the biases. In total there are \(\nu\) activation layers inserted between \(\nu+1\) fully connected layers. \(z\) represents the inputs to the neural network and \(\hat{x}\) is the output vector, as we will use such a neural network to approximate the \(T^{\dagger}\) mapping in the KKL observer.

Given a neural network with fixed parameters \(\theta=(W^{0},b^{0},\ldots,W^{\nu},b^{\nu})\), a rough estimate of the Lipschitz

Fig. 1: KKL observer with a Lipschitz-bounded neural network to be trained.
constant of \(S\) can be obviously obtained as

\[L_{S}(\theta)=\prod_{\ell=0}^{\nu}\|W^{\ell}\|_{2}, \tag{5}\]

where \(\|\cdot\|_{2}\) for a matrix refers to its operator norm induced by the \(\ell_{2}\)-norm of vectors, i.e., its largest singular value. To reduce the conservativeness, Fazlyab et al. [25] leverages the control-theoretic tool of integral quadratic constraints to formulate the Lipschitz bound condition as a linear matrix inequality, thus estimating the Lipschitz constants and training Lipschitz-bounded neural networks through solving semidefinite programming problems [27]. The pertinent matrix size, however, proportionally scales with the total number of neurons, which results in high computational complexity unless the neural network is very small.

The recent work of Wang and Manchester [28] proposed a _direct parameterization_ approach to accommodate Lipschitz bound by a special design of the neural network architecture instead of imposing extra parameter constraints. By this approach, the training of neural networks is an unconstrained optimization problem and is thus amenable to the typical, computationally lightweight back-propagation (BP) routine. Wang-Manchester direct parameterization is conceptually related to, and arguably motivated by, the theory of controller parameterization [30, 31].

**Definition 2** (\(1\)-Lipschitz sandwich layer, cf. [28]).: _Given parameters \(X\in\mathbb{R}^{d\times d}\), \(Y\in\mathbb{R}^{c\times d}\), \(s\in\mathbb{R}^{d}\), and \(b\in\mathbb{R}^{d}\), a \(1\)-Lipschitz sandwich layer is defined as such a mapping \(\Xi:\mathbb{R}^{c}\rightarrow\mathbb{R}^{d}\) that maps any \(h\in\mathbb{R}^{c}\) into a \(\Xi(h;X,Y,s,b)\in\mathbb{R}^{d}\) according to the following formulas:_

\[Z =X-X^{\top}+Y^{\top}Y,\ \Psi_{s}=\mathrm{diag}(e^{s}) \tag{6}\] \[M_{X,Y} =\left[(I+Z)^{-1}(I-Z)\right]^{\top},\] \[N_{X,Y} =\left[-2Y(I+Z)^{-1}\right]^{\top},\] \[\Xi(h) =\sqrt{2}M_{X,Y}^{\top}\Psi_{s}\sigma(\sqrt{2}\Psi_{s}^{-1}N_{X, Y}h+b).\]

It turns out that the Lipschitz constant of the above-defined sandwich layer is guaranteed to be upper bounded by \(1\)[28, Theorem 3.3]. The mapping from the input \(h\) to the output \(\Xi(h)\) can be regarded as comprising of an activation layer in the midst of two fully connected layers with related parameters. The operation from \((X,Y)\) to \((M,N)\) is known as the _Cayley transform_. The structure and the parameters of a sandwich layer is shown in Fig. 2.

Thus, by stacking a number of such sandwich layers after a scaling by \(\sqrt{\gamma}\) and before a non-activated half-sandwich layer (meaning a layer containing only the terms in the parentheses of \(\Xi\) as in Equation (6)), a neural network with Lipschitz bound \(\gamma\) can be obtained, for any provided \(\gamma>0\).

**Definition 3** (Wang-Manchester network).: _In this work, we refer to Wang-Manchester network, \(S(\cdot|\theta)\), by a neural network in the following architecture:_

\[h^{0} =\sqrt{\gamma}z; \tag{7}\] \[h^{\ell+1} =\Xi(h^{\ell};X^{\ell},Y^{\ell},s^{\ell},b^{\ell}),\ \ell=0,1,\ldots,\nu-1;\] \[\hat{x} =\sqrt{\gamma}N_{X^{\nu},Y^{\nu}}h^{\nu}+b^{\nu}.\]

_Here the parameters include_

\[\theta=\{X^{\ell},Y^{\ell},s^{\ell},b^{\ell}\}_{\ell=0}^{\nu-1}\cup\{X^{\nu}, Y^{\nu},b^{\nu}\}\]

_which can be trained in an unconstrained way using back-propagation. The inputs and outputs of the network are \(z\) and \(\hat{x}\), respectively._

The above-defined Wang-Manchester network satisfies \(\|S(\cdot|\theta)\|_{\mathrm{Lip}}\leq\gamma\). In this work, the network is defined and trained with data using PyTorch (version 2.0.1) on Google Colaboratory, which allows the auto-differentiation of a user-defined loss function with respect to the neural network parameters for the parameters to be iteratively updated.

## III Analysis on the Generalized Loss

Here we shall provide a justification for requiring a Lipschitz bound on the neural network. We will make the following standing assumptions on the training data collection procedure for subsequent analysis.

**Assumption 1** (Ergodicity).: _Assume that a sample trajectory is collected from the system, whose initial state is sampled from a probability distribution \(\mathcal{F}\) on \(\mathcal{X}\). The distribution \(\mathcal{F}\) is time-invariant (i.e., an eigenmeasure of the Perron-Frobenius operator), so that any point of the trajectory comes from \(\mathcal{F}\)._

Suppose that The LTI dynamics of the KKL observer, \((A,B)\), is fixed. Then the observer states can be simulated from this linear dynamics.

**Assumption 2** (Noisy measurements).: _Assume that the input signal for this LTI system is not noise-free measurements \(y=h(x)\), but instead containing a white noise of unknown covariance \(\sigma^{2}\). In other words, the simulation from \(y\) to \(z\) is_

\[\begin{split}&\dot{z}=Ax+By+w,\quad\mathbb{E}[w(t)]=0,\,\forall t \in\mathbb{R}\\ &\mathbb{E}[w(t)w(s)]=\delta(t-s)\sigma^{2},\,\forall t,s\in \mathbb{R}.\end{split} \tag{8}\]

In this way, the collected sample, denoted as \(\{(x(t_{i}),z(t_{i}))\}_{i=1}^{m}=\{(x_{i},z_{i})\}_{i=1}^{m}\), in fact satisfies the following relation:

\[z_{i}=\bar{z}_{i}+v_{i},\quad\delta_{i}=\int_{-\infty}^{t_{i}}g(\tau)w(t_{i}- \tau)d\tau. \tag{9}\]

Here \(g(\tau)\) is the impulse response of LTI system \((A,B)\); \(\bar{z}\) is the value of \(z(t_{i})\) that would be otherwise obtained if there were no white noises in the output measurements.

**Assumption 3** (Sufficient decay).: _After a significantly long time \(t_{\epsilon}\), \(\|z-T(x)\|\leq\epsilon\) for a small enough \(z\). Here \(T\) is the nonlinear immersion map specified by (3)._

Fig. 2: A sandwich layer and its parameters.
Then, \(\|\bar{z}_{i}-T(x_{i})\|\leq\epsilon\). Thus, we may write

\[z_{i}=T(x_{i})+v_{i}+v_{i}^{\prime},\quad\|v_{i}^{\prime}\|\leq\epsilon. \tag{10}\]

Now we suppose that the sample \(\{(x_{i},z_{i})\}_{i=1}^{m}\) is used to train a neural network \(S(\cdot|\theta)\), which gives the state observations \(\hat{x}_{i}=S(z_{i}|\theta)\), and that the resulting empirical loss, if defined as the average squared observation error, is

\[\hat{R}_{S}(\theta):=\frac{1}{m}\sum_{i=1}^{m}\|\hat{x}_{i}-x_{i}\|^{2}. \tag{11}\]

Then we get

\[\hat{R}_{S}(\theta)=\frac{1}{m}\sum_{i=1}^{m}\left\|S\left(T(x_{i})+v_{i}+v_{i }^{\prime}|\theta\right)-x_{i}\right\|^{2}. \tag{12}\]

**Assumption 4**.: _Assume that the probability distribution \(\mathcal{F}\) is supported by a compact set, i.e., if \(x\sim\mathcal{F}\), then \(x\) should be almost surely bounded._

It follows that both \(S(\cdot|\theta)\) and \(T\) should be Lipschitz continuous. Denote their Lipschitz constants as \(L_{S}(\theta)\) and \(L_{T}\), respectively. We have

\[\|S\left(T(x_{i})+\delta_{i}+\delta_{i}^{\prime}|\theta\right)-S\left(T(x_{i}) |\theta\right)\|\leq L_{S}(\theta)L_{T}(\|v_{i}\|+\epsilon). \tag{13}\]

Denote \(D\) as the essential upper bound of \(\|x\|\) on the distribution \(\mathcal{F}\). As such, without loss of generality, let \(S(T(0))=0\). Then \(\|x-S(T(x))\|\leq(L_{S}(\theta)L_{T}+1)D\) almost surely. Combining the above two equations, we further get

\[\frac{1}{m}\sum_{i=1}^{m}\|x_{i}-S(T(x_{i})|\theta)\|^{2}\leq \hat{R}_{S}(\theta) \tag{14}\] \[\quad+\frac{1}{m}\sum_{i=1}^{m}L_{S}(\theta)L_{T}(L_{S}(\theta)L _{T}+1)D(\|v_{i}\|+\epsilon)\] \[\quad+\frac{1}{m}\sum_{i=1}^{m}L_{S}^{2}(\theta)L_{T}^{2}(\|v_{i} \|+\epsilon)^{2}.\]

That is,

\[\frac{1}{m}\sum_{i=1}^{m}\|x_{i}-S(T(x_{i})|\theta)\|^{2}\leq \hat{R}_{S}(\theta) \tag{15}\] \[\quad+\frac{1}{m}\sum_{i=1}^{m}(L_{S}(\theta)L_{T}+1)^{2}\left(D+ \|v_{i}\|+\epsilon\right)(\|v_{i}\|+\epsilon).\]

The left-hand side gives an estimation of the empirical loss when observing the states from perfect output measurements (namely when \(z_{i}=T(x_{i})\), \(i=1,\ldots,m\)). Further expanding the last term and applying Cauchy-Schwarz inequality, we have

\[\frac{1}{m}\sum_{i=1}^{m}\|x_{i}-S(T(x_{i})|\theta)\|^{2}\leq\hat {R}_{S}(\theta)+(L_{S}(\theta)L_{T}+1)^{2}\times \tag{16}\] \[\quad\left[\frac{1}{m}\sum_{i=1}^{m}\|v_{i}\|^{2}+(D+2\epsilon) \left(\sum_{i=1}^{m}\|v_{i}\|^{2}\right)^{1/2}+(D+\epsilon)\epsilon\right].\]

Given that \(v_{i}\) is the response of LTI system \((A,B)\) to a white noise of covariance \(\sigma^{2}\), \(\mathbb{E}(\|v_{i}\|^{2})=h^{2}\sigma^{2}\) where \(h\) is the \(H_{2}\)-norm of the system \((A,B)\) where \(A\) is Hurwitz. Therefore,

\[\mathbb{E}\left(\frac{1}{m}\sum_{i=1}^{m}\|v_{i}\|^{2}\right)=h^{2}\sigma^{2}. \tag{17}\]

Let \(\alpha\) be a small positive number. With confidence \(1-\alpha/2\), a conservative estimation for its upper bound can be found according to Markov inequality:

\[\frac{1}{m}\sum_{i=1}^{m}\|v_{i}\|^{2}\leq\frac{1}{1-\alpha/2}h^{2}\sigma^{2}. \tag{18}\]

Therefore,

\[\frac{1}{m}\sum_{i=1}^{m}\|x_{i}-S(T(x_{i})|\theta)\|^{2}\leq\hat {R}_{S}(\theta)+(L_{S}(\theta)L_{T}+1)^{2}\times \tag{19}\] \[\quad\left[\frac{h^{2}\sigma^{2}}{1-\alpha/2}+(D+2\epsilon)\frac{ h\sigma}{\sqrt{1-\alpha/2}}+(D+\epsilon)\epsilon\right].\]

Finally, we note that for \(x\sim\mathcal{F}\), now that \(\|x-S(T(x)|\theta)\|\leq(L_{S}(\theta)L_{T}+1)D\) almost surely, by Hoeffding's inequality, for any \(\varepsilon>0\),

\[\mathbb{P}\bigg{(}\bigg{|}\frac{1}{m}\sum_{i=1}^{m}\|x_{i}-S(T(x_{ i})|\theta)\|^{2}-\mathbb{E}\left(\|x-S(T(x))\|^{2}\right)\bigg{|} \tag{20}\] \[\geq(L_{S}(\theta)L_{T}+1)^{2}D^{2}\varepsilon\bigg{)}\leq 2\exp \left(-2m\varepsilon^{2}\right).\]

Thus, with confidence \(1-\alpha/2\), we have

\[\left|\frac{1}{m}\sum_{i=1}^{m}\|x_{i}-S(T(x_{i})|\theta)\|^{2}- \mathbb{E}\left(\|x-S(T(x)|\theta)\|^{2}\right)\bigg{|}\right. \tag{21}\] \[\quad<(L_{S}(\theta)L_{T}+1)^{2}D^{2}\sqrt{\frac{\ln(4/\alpha)}{2m }}.\]

Combining (19) and (21), we have the following theorem.

**Theorem 1**.: _Under the afore-mentioned assumptions, the generalization loss, defined as_

\[R_{S}(\theta)=\mathbb{E}\left(\|x-S(T(x)|\theta)\|^{2}\right), \tag{22}\]

_is related to the empirical loss as defined in (11) by_

\[R_{S}(\theta)<\hat{R}_{S}(\theta)+(L_{S}(\theta)L_{T}+1)^{2}\Delta(h,\sigma, \alpha,\epsilon). \tag{23}\]

_with confidence \(1-\alpha\) (\(\alpha\in(0,1)\)). Here_

\[\Delta(h,\sigma,\alpha,\epsilon)= D^{2}\sqrt{\frac{\ln(4/\alpha)}{2m}}+\frac{h^{2}\sigma^{2}}{1- \alpha/2} \tag{24}\] \[+(D+2\epsilon)\frac{h\sigma}{\sqrt{1-\alpha/2}}+(D+\epsilon)\epsilon.\]

The theorem shows that the Lipschitz constant of the neural network trained plays an important role in the generalized performance of the resulting state observer. The effect of \(L_{S}(\theta)\) is mainly that of amplifying the first and third terms defined on the right-hand side of (24), supposing that \(\sigma\)
and \(\epsilon\) are small enough. These two terms respectively arise from (i) the overall upper bound of the observation error \(\|x-S(T(x)|\theta)\|\), which acts as a coefficient before the Hoeffding term \(\sqrt{\ln(4/\alpha)/2m}\), and (ii) the effect of noisy measurements on the observer states.

**Remark 1**.: _It is noted that the performance bound stated in the above theorem can be conservative. The conclusion that \(L_{S}(\theta)\) amplifies the generalization error and measurement noise should be considered as qualitative. The theorem also does not suggest a tractable algorithm to optimize the selection of \((A,B)\) along with the neural network \(S(\cdot|\theta)\), as the dependence of \(L_{T}\) on \((A,B)\) is highly implicit. Hence, this paper does not consider the problem of simultaneously training \((A,B)\) and the neural network._

## IV Case Study

Let us consider a Lorenz system in a 3-dimensional state space with chaotic behavior. The equation is written as:

\[\dot{x}_{1} =10(x_{2}-x_{1}), \tag{25}\] \[\dot{x}_{2} =x_{1}(28-10x_{3})-x_{2},\] \[\dot{x}_{3} =10x_{1}x_{2}-(8/3)x_{3}.\]

Suppose that the measurement used for state observation is \(y=x_{2}\), where a white noise exists. We assign different values to the variance of the measurement noise and investigate how the resulting neural network should be chosen differently. To simulate the process we will use a sampling time of \(0.01\). The LTI part of the KKL observer, \(A=-\mathrm{diag}(8,4,2,1)\) and \(B=[1,1,1,1]^{\top}\) are chosen. At the beginning of the observer simulation, \(z(0)=0\) is set as the initial condition; we simulate the dynamics until \(t=500\) and randomly collect \(m=2000\) time instants between \(t=20\) and \(t=500\) as the training data.

Consider first the case with noiseless measurement (\(\sigma=0\)). The sample \(\{(x_{i},z_{i})\}_{i=1}^{2000}\) is plotted in Fig. 3, which shows that the data points are representative on the forward invariant set of the system, and that the observer states \(z_{i}\) indeed captures the structure of such a Lorenz attractor in a \(4\)-dimensional space. Hence, we train the Wang-Manchester network using a randomly selected \(80\%\) of the sample under the mean-squares loss metric, and validate using the remaining \(20\%\) sample points. Stochastic gradient descent (SGD) algorithm with a learning rate of \(10^{-3}\) is used for optimization. The number of epochs is empirically tuned to \(300\). The neural network has \(2\) hidden layers, each containing \(8\) neurons, resulting in \(292\) parameters to train in total. After training, the Lipschitz constant is evaluated a posteriori via the semidefinite programming approach of Fazlyab et al. [25] using cvxpy, which costs approximately \(1.5\) seconds (for a randomly initialized network).

Varying the prior bound on the Lipschitz constant, the resulting training loss, validation loss, and the posterior Lipschitz bound obtained from the same training conditions are illustrated in Fig. 4. The following observations can be made from these results.

* As anticipated, as the set bound on the Lipschitz bound increases, the Lipschitz constant of the trained neural network becomes higher. The Lipschitz constants estimated a posteriori are lower than the prior bound on the Wang-Manchester network, validating the direct parameterization approach on constraining the slope. On the other hand, the actually posterior Lipschitz constant has an increasingly large lag behind the prior bound; for example, when the prior bound is \(1000\), the \(L_{S}\) after training does not exceed \(300\). This indicates that even for the training objective alone, there is a "resistance" to pursue the maximally possible Lipschitz constant.
* When the Lipschitz bound is small, relaxing the restriction on \(L_{S}\) is beneficial for decreasing the training loss as well as the validation loss, showing that the Lipschitz bound is a bottleneck causing underfitting. When \(L_{S}\) is high enough, such underfitting no longer exists; instead, overfitting will appear, with rising training and

Fig. 3: Sample collected from the Lorenz system.
validation losses. The overfitting phenomenon is more significant when the noise is large. Thus, there should be optimal values to be set as the Lipschitz bound.
* Depending on the noise magnitude, the deviation of posterior Lipschitz constant from the prior bound and the emergence of overfitting phenomenon occur at different threshold values of the Lipschitz bound. Thus, the Lipschitz bound to be used for neural network training should be tuned differently as the noise intensity varies. For example, at \(\sigma=1\), a suitable choice can be \(\gamma=100\), whereas at \(\sigma=5\) and \(\sigma=10\), \(\gamma\) can be chosen as \(30\) and \(10\), respectively.

Now suppose that at the observer design stage, the Wang-Manchester network is trained by the simulated data from a perfect digital twin of the true dynamics, i.e., \(\sigma=0\); yet, when applying the network trained to observe the states of the physical system, the environment is noisy. In Fig. 5, the resulting loss (mean squared state observation error) is plotted against varying prior Lipschitz bounds under multiple values of the environment noise magnitude. It is seen that when the noise is low, roughly speaking, increasing \(L_{S}\) leads to monotonic decrease in the observation error within a large range. On the other hand, when the environment is highly noisy (e.g., when \(\sigma\geq 3\)), the Lipschitz bound has a severe effect on the generalization loss, and since the achievable performance is restrictive, the fine-tuning of Lipschitz bound as a hyperparameter becomes critical.

Finally, the performance of the state observer is examined. Consider using the network trained with noiseless simulation data under the prior Lipschitz bound \(L_{S}=10\), and applying it to environments with noise \(\sigma=0.1\), \(0.3\), \(1.0\), \(3.0\). The trajectories of the three components of estimated states by the observer are plotted against the true states in Fig. 6, within a time horizon of \(10\) time units. Naturally, when \(\sigma\) is low, the state estimates can well track the true states and capture the trends in the correct directions; as \(\sigma\) increases, the accuracy is lowered and the signals constructed by the observer are more noisy, occasionally yielding incorrect directions of evolution (e.g., on \(3<t<4\) or \(8<t<9\), where the states swing between the two foils of the Lorenz attractor). Overall, the state estimates mollifies the true state trajectories, which is due to the structure of our KKL observer - a linear filter (LTI system) as the state dynamics and a Lipschitz-bounded neural network as the static output map.

## V Conclusions and Discussions

This work leverages the recent tools of Lipschitz-bounded neural networks for the synthesis of nonlinear state observers in a model-free setting. The observer, which has a Kazantzis-Kravaris structure, turns out to have a provable generalization performance that is related to the Lipschitz constant of the trained neural network (which represents the mapping from the observer states to the plant states). As such, by varying the Lipschitz bound and re-training the neural network, the optimal training result can yield the minimum generalized state observation error. The importance of bounding the Lipschitz constant has been demonstrated by a numerical case study on the Lorenz system.

Fig. 4: Loss and Lipschitz constants under different prior Lipschitz bounds. (Blue wedges: training loss, blue circles: validation loss, green circles: prior Lipschitz bound; green wedges: posterior Lipschitz bound.)

Fig. 5: Errors of noiselessly trained observers in noisy environments.
We implicitly assumed here that a simulator of the dynamics is available, so that the true states' trajectories can be used to train the neural network. However, such ground truth for supervised learning may not actually exist in real applications, i.e., only inputs and outputs are recorded, yet a state observation mechanism is still needed or desired for feedback control. To this end, the author's recent work [32] proposed a data-driven KKL observer by appending a kernel dimensionality reduction scheme to the LTI dynamics, thus obtaining estimates that are diffeomorphic to the states.

Also, the current approach is yet restricted to autonomous systems. For control purposes, it should be further extended to non-autonomous ones, where the Bernard-Andrieu observer structure [18] is anticipated. Also, the application of such data-driven state observers to learning control-relevant properties of nonlinear dynamical systems and controller synthesis [33, 34] is undergoing active research.
