This paper was converted on www.awesomepapers.org from LaTeX by an anonymous user.
Want to know more? Visit the Converter page.

Neural Delay Differential Equations

Qunxi Zhu, Yao Guo & Wei Lin
School of Mathematical Science, Research Institute of Intelligent Complex Systems and ISTBI
State Key Laboratory of Medical Neurobiology and MOE Frontiers Center for Brain Science
Fudan University
Shanghai 200433, China
{qxzhu16,yguo,wlin}@fudan.edu.cn
http://homepage.fudan.edu.cn/weilin, To whom correspondence should be addressed: Q.Z., Y.G., and W.L.
Abstract

Neural Ordinary Differential Equations (NODEs), a framework of continuous-depth neural networks, have been widely applied, showing exceptional efficacy in coping with some representative datasets. Recently, an augmented framework has been successfully developed for conquering some limitations emergent in application of the original framework. Here we propose a new class of continuous-depth neural networks with delay, named as Neural Delay Differential Equations (NDDEs), and, for computing the corresponding gradients, we use the adjoint sensitivity method to obtain the delayed dynamics of the adjoint. Since the differential equations with delays are usually seen as dynamical systems of infinite dimension possessing more fruitful dynamics, the NDDEs, compared to the NODEs, own a stronger capacity of nonlinear representations. Indeed, we analytically validate that the NDDEs are of universal approximators, and further articulate an extension of the NDDEs, where the initial function of the NDDEs is supposed to satisfy ODEs. More importantly, we use several illustrative examples to demonstrate the outstanding capacities of the NDDEs and the NDDEs with ODEs’ initial value. Specifically, (1) we successfully model the delayed dynamics where the trajectories in the lower-dimensional phase space could be mutually intersected, while the traditional NODEs without any argumentation are not directly applicable for such modeling, and (2) we achieve lower loss and higher accuracy not only for the data produced synthetically by complex models but also for the real-world image datasets, i.e., CIFAR10, MNIST, and SVHN. Our results on the NDDEs reveal that appropriately articulating the elements of dynamical systems into the network design is truly beneficial to promoting the network performance.

1 Introduction

A series of recent works have revealed a close connection between neural networks and dynamical systems (E, 2017; Li et al., 2017; Haber & Ruthotto, 2017; Chang et al., 2017; Li & Hao, 2018; Lu et al., 2018; E et al., 2019; Chang et al., 2019; Ruthotto & Haber, 2019; Zhang et al., 2019a; Pathak et al., 2018; Fang et al., 2018; Zhu et al., 2019; Tang et al., 2020). On one hand, the deep neural networks can be used to solve the ordinary/partial differential equations that cannot be easily computed using the traditional algorithms. On the other hand, the elements of the dynamical systems can be useful for establishing novel and efficient frameworks of neural networks. Typical examples include the Neural Ordinary Differential Equations (NODEs), where the infinitesimal time of ordinary differential equations is regarded as the “depth” of a considered neural network (Chen et al., 2018).

Though the advantages of the NODEs were demonstrated through modeling continuous-time datasets and continuous normalizing flows with constant memory cost (Chen et al., 2018), the limited capability of representation for some functions were also studied (Dupont et al., 2019). Indeed, the NODEs cannot be directly used to describe the dynamical systems where the trajectories in the lower-dimensional phase space are mutually intersected. Also, the NODEs cannot model only a few variables from some physical or/and physiological systems where the effect of time delay is inevitably present. From a view point of dynamical systems theory, all these are attributed to the characteristic of finite-dimension for the NODEs.

In this article, we propose a novel framework of continuous-depth neural networks with delay, named as Neural Delay Differential Equations (NDDEs). We apply the adjoint sensitivity method to compute the corresponding gradients, where the obtained adjoint systems are also in a form of delay differential equations. The main virtues of the NDDEs include:

  • feasible and computable algorithms for computing the gradients of the loss function based on the adjoint systems,

  • representation capability of the vector fields which allow the intersection of the trajectories in the lower-dimensional phase space, and

  • accurate reconstruction of the complex dynamical systems with effects of time delays based on the observed time-series data.

2 Related Works

NODEs Inspired by the residual neural networks (He et al., 2016) and the other analogous frameworks, the NODEs were established, which can be represented by multiple residual blocks as

𝒉t+1=𝒉t+𝒇(𝒉t,𝒘t),{\bm{h}}_{t+1}={\bm{h}}_{t}+{\bm{f}}({\bm{h}}_{t},{\bm{w}}_{t}),

where 𝒉t{\bm{h}}_{t} is the hidden state of the tt-th layer, 𝒇(𝒉t;𝒘t){\bm{f}}({\bm{h}}_{t};{\bm{w}}_{t}) is a differential function preserving the dimension of 𝒉t{\bm{h}}_{t}, and 𝒘t{\bm{w}}_{t} is the parameter pending for learning. The evolution of 𝒉t{\bm{h}}_{t} can be viewed as the special case of the following equation

𝒉t+Δt=𝒉t+Δt𝒇(𝒉t,𝒘t){\bm{h}}_{t+\Delta t}={\bm{h}}_{t}+\Delta t\cdot{\bm{f}}({\bm{h}}_{t},{\bm{w}}_{t})

with Δt=1\Delta t=1. As suggested in (Chen et al., 2018), all the parameters 𝒘t{\bm{w}}_{t} are unified into 𝒘{\bm{w}} for achieving parameter efficiency of the NODEs. This unified operation was also employed in the other neural networks, such as the recurrent neural networks (RNNs) (Rumelhart et al., 1986; Elman, 1990) and the ALBERT (Lan et al., 2019). Letting Δt0\Delta t\rightarrow 0 and using the unified parameter 𝒘{\bm{w}} instead of 𝒘t{\bm{w}}_{t}, we obtain the continuous evolution of the hidden state 𝒉t{\bm{h}}_{t} as

limΔt0𝒉t+Δt𝒉tΔt=d𝒉tdt=𝒇(𝒉t,t;𝒘),\lim_{\Delta t\rightarrow 0}\frac{{\bm{h}}_{t+\Delta t}-{\bm{h}}_{t}}{\Delta t}=\frac{d{{\bm{h}}_{t}}}{dt}={\bm{f}}({\bm{h}}_{t},t;{\bm{w}}),

which is in the form of ordinary differential equations. Actually, the NODEs can act as a feature extraction, mapping an input to a point in the feature space by computing the forward path of a NODE as:

𝒉(T)=𝒉(0)+0T𝒇(𝒉t,t;𝒘)𝑑t,𝒉(0)=input,{\bm{h}}(T)={\bm{h}}(0)+\int_{0}^{T}{\bm{f}}({\bm{h}}_{t},t;{\bm{w}})dt,~{}~{}{\bm{h}}(0)=\mbox{input},

where 𝒉(0)=input{\bm{h}}(0)=\mbox{input} is the original data point or its transformation, and TT is the integration time (assuming that the system starts at t=0t=0).

Under a predefined loss function L(𝒉(T))L({\bm{h}}(T)), (Chen et al., 2018) employed the adjoint sensitivity method to compute the memory-efficient gradients of the parameters along with the ODE solvers. More precisely, they defined the adjoint variable, 𝝀(t)=L(𝒉(T))𝒉(t)\bm{\lambda}(t)=\frac{\partial L({\bm{h}}(T))}{\partial{\bm{h}}(t)}, whose dynamics is another ODE, i.e.,

d𝝀(t)dt=𝝀(t)f(𝒉t,t;𝒘)𝒉t.\frac{d\bm{\lambda}(t)}{dt}=-\bm{\lambda}(t)^{\top}\frac{\partial f({\bm{h}}_{t},t;{\bm{w}})}{\partial{\bm{h}}_{t}}. (1)

The gradients are computed by an integral as:

dLd𝒘=T0𝝀(t)f(𝒉t,t;𝒘)𝒘dt.\frac{dL}{d{\bm{w}}}=\int_{T}^{0}-\bm{\lambda}(t)^{\top}\frac{\partial f({\bm{h}}_{t},t;{\bm{w}})}{\partial{\bm{w}}}dt. (2)

(Chen et al., 2018) calculated the gradients by calling an ODE solver with extended ODEs (i.e., concatenating the original state, the adjoint, and the other partial derivatives for the parameters at each time point into a single vector). Notably, for the regression task of the time series, the loss function probably depend on the state at multiple observational times, such as the form of L(h(t0),h(t1),,h(tn))L(h(t_{0}),h(t_{1}),...,h(t_{n})). Under such a case, we must update the adjoint state instantly by adding the partial derivative of the loss at each observational time point.

As emphasized in (Dupont et al., 2019), the flow of the NODEs cannot represent some functions omnipresently emergent in applications. Typical examples include the following two-valued function with one argument: g1-D(1)=1g_{\mbox{\rm 1-D}}(1)=-1 and g1-D(1)=1g_{\mbox{\rm 1-D}}(-1)=1. Our framework desires to conquer the representation limitation observed in applying the NODEs.

Refer to caption
Figure 1: Sketchy diagrams of the NODEs and the NDDES, respectively, with the initial value 𝒉(0){\bm{h}}(0) and the initial function ϕ(t)\phi(t). The NODEs and the NDDEs act as the feature extractors, and the following layer processes the features with a predefined loss function.

Optimal control As mentioned above, a closed connection between deep neural networks and dynamical systems have been emphasized in the literature and, correspondingly, theories, methods and tools of dynamical systems have been employed, e.g. the theory of optimal control (E, 2017; Li et al., 2017; Haber & Ruthotto, 2017; Chang et al., 2017; Li & Hao, 2018; E et al., 2019; Chang et al., 2019; Ruthotto & Haber, 2019; Zhang et al., 2019a). Generally, we model a typical task using a deep neural network and then train the network parameters such that the given loss function can be reduced by some learning algorithm. In fact, training a network can be seen as solving an optimal control problem on difference or differential equations  (E et al., 2019). The parameters act as a controller with a goal of finding an optimal control to minimize/maximize some objective function. Clearly, the framework of the NODEs can be formulated as a typical problem of optimal control on ODEs. Additionally, the framework of NODEs has been generalized to the other dynamical systems, such as the Partial Differential Equations (PDEs) (Han et al., 2018; Long et al., 2018; 2019; Ruthotto & Haber, 2019; Sun et al., 2020) and the Stochastic Differential Equations (SDEs) (Lu et al., 2018; Sun et al., 2018; Liu et al., 2019), where the theory of optimal control has been completely established. It is worthwhile to mention that the optimal control theory is tightly connected with and benefits from the method of the classical calculus of variations (Liberzon, 2011). We also will transform our framework into an optimal control problem, and finally solve it using the method of the calculus of variations.

3 The framework of NDDEs

3.1 Formulation of NDDEs

Refer to caption
Figure 2: (Right) Two continuous trajectories generated by the DDEs are intersected, mapping -1 (resp., 1) to 1 (resp., -1), while (Left) the ODEs cannot represent such mapping.

In this section, we establish a framework of continuous-depth neural networks. To this end, we first introduce the concept of delay deferential equations (DDEs). The DDEs are always written in a form where the derivative of a given variable at time tt is affected not only by the current state of this variable but also the states at some previous time instants or time durations (Erneux, 2009). Such kind of delayed dynamics play an important role in description of the complex phenomena emergent in many real-world systems, such as physical, chemical, ecological, and physiological systems. In this article, we consider a system of DDE with a single time delay:

{d𝒉tdt=f(𝒉t,𝒉tτ,t;𝒘),t>=0,𝒉(t)=ϕ(t),t<=0,\left\{\begin{array}[]{ll}\frac{d{{\bm{h}}_{t}}}{dt}=f({\bm{h}}_{t},{\bm{h}}_{t-\tau},t;{\bm{w}}),&t>=0,\\ {\bm{h}}(t)={{\phi}}(t),&t<=0,\end{array}\right.

where the positive constant τ\tau is the time delay and 𝒉(t)=ϕ(t){\bm{h}}(t)={\phi}(t) is the initial function before the time t=0t=0. Clearly, in the initial problem of ODEs, we only need to initialize the state of the variable at t=0t=0 while we initialize the DDEs using a continuous function. Here, to highlight the difference between ODEs and DDEs, we provide a simple example:

{dxtdt=2xtτ,t>=0,x(t)=x0,t<=0.\left\{\begin{array}[]{ll}\frac{d{x_{t}}}{dt}=-2x_{t-\tau},&t>=0,\\ x(t)=x_{0},&t<=0.\end{array}\right.

where τ=1\tau=1 (with time delay) or τ=0\tau=0 (without time delay). As shown in Figure 2, the DDE flow can map -1 to 1 and 1 to -1; nevertheless, this cannot be made for the ODE whose trajectories are not intersected with each other in the tt-xx space in Figure 2.

3.2 Adjoint Method for NDDEs

Assume that the forward pass of DDEs is complete. Then, we need to compute the gradients in a reverse-mode differentiation by using the adjoint sensitivity method (Chen et al., 2018; Pontryagin et al., 1962). We consider an augmented variable, named as adjoint and defined as

𝝀(t)=L(𝒉(T))𝒉(t),\bm{\lambda}(t)=\frac{\partial L({\bm{h}}(T))}{\partial{\bm{h}}(t)}, (3)

where L()L(\cdot) is the loss function pending for optimization. Notably, the resulted system for the adjoint is in a form of DDE as well.

Theorem 1

(Adjoint method for NDDEs). Consider the loss function L()L(\cdot). Then, the dynamics of adjoint can be written as

{d𝝀(t)dt=𝝀(t)f(𝒉t,𝒉tτ,t;𝒘)𝒉t𝝀(t+τ)f(𝒉t+τ,𝒉t,t;𝒘)𝒉tχ[0,Tτ](t),t<=T𝝀(T)=L(𝒉(T))𝒉(T),\left\{\begin{aligned} \frac{d\bm{\lambda}(t)}{dt}&=-\bm{\lambda}(t)^{\top}\frac{\partial f({\bm{h}}_{t},{\bm{h}}_{t-\tau},t;{\bm{w}})}{\partial{\bm{h}}_{t}}-\bm{\lambda}(t+\tau)^{\top}\frac{\partial f({\bm{h}}_{t+\tau},{\bm{h}}_{t},t;{\bm{w}})}{\partial{\bm{h}}_{t}}\chi_{[0,T-\tau]}(t),~{}t<=T\\ \bm{\lambda}(T)&=\frac{\partial L({\bm{h}}(T))}{\partial{\bm{h}}(T)},\end{aligned}\right. (4)

where χ[0,Tτ]()\chi_{[0,T-\tau]}(\cdot) is a typical characteristic function.

We provide two ways to prove Theorem 1, which are, respectively, shown in Appendix. Using 𝒉(t){\bm{h}}(t) and 𝝀(t)\bm{\lambda}(t), we compute the gradients with respect to the parameters 𝒘{\bm{w}} as:

dLd𝒘=T0𝝀(t)f(𝒉t,𝒉tτ,t;𝒘)𝒘dt.\frac{dL}{d{\bm{w}}}=\int_{T}^{0}-\bm{\lambda}(t)^{\top}\frac{\partial f({\bm{h}}_{t},{\bm{h}}_{t-\tau},t;{\bm{w}})}{\partial{\bm{w}}}dt. (5)

Clearly, when the delay τ\tau approaches zero, the adjoint dynamics degenerate as the conventional case of the NODEs (Chen et al., 2018).

We solve the forward pass of 𝒉{\bm{h}} and backward pass for 𝒉{\bm{h}}, 𝝀\bm{\lambda} and dLd𝒘\frac{dL}{d{\bm{w}}} by a piece-wise ODE solver, which is shown in Algorithm 1. For simplicity, we denote by f(t)f(t) and g(t)g(t) the vector filed of 𝒉{\bm{h}} and 𝝀\bm{\lambda}, respectively. Moreover, in this paper, we only consider the initial function ϕ(t)\phi(t) as a constant function, i.e., ϕ(t)=𝒉0\phi(t)={\bm{h}}_{0}. Assume that T=nτT=n\cdot\tau and denote fk(t)=f(kτ+t)f_{k}(t)=f(k\cdot\tau+t), gk(t)=g(kτ+t)g_{k}(t)=g(k\cdot\tau+t) and 𝝀k(t)=𝝀(kτ+t)\bm{\lambda}_{k}(t)=\bm{\lambda}(k\cdot\tau+t).

Algorithm 1 Piece-wise reverse-mode derivative of an DDE initial function problem

Input: dynamics parameters 𝒘{\bm{w}}, time delay τ\tau, start time 0, stop time T=nτT=n\cdot\tau, final state 𝒉(T){\bm{h}}(T), loss gradient L/𝒉(T)\partial{L}/\partial{{\bm{h}}(T)}
    L𝒘=0|𝒘|\frac{\partial{L}}{\partial{{\bm{w}}}}=0_{|{\bm{w}}|}
    for ii in range(n1,1,1n-1,-1,-1):
        s0=[𝒉(T),𝒉(Tτ),,𝒉(τ),L𝒉(T),,L𝒉((i+1)τ),L𝒘]s_{0}=[{\bm{h}}(T),{\bm{h}}(T-\tau),...,{\bm{h}}(\tau),\frac{\partial{L}}{\partial{{\bm{h}}(T)}},...,\frac{\partial{L}}{\partial{{\bm{h}}((i+1)\cdot{\tau})}},\frac{\partial{L}}{\partial{{\bm{w}}}}]
        def aug¯{\underline{~{}}}dynamics([𝒉n1(t){\bm{h}}_{n-1}(t),…,𝒉0(t){\bm{h}}_{0}(t), 𝝀n1(t)\bm{\lambda}_{n-1}(t),..,𝝀i(t)\bm{\lambda}_{i}(t), .], tt, 𝒘{\bm{w}}):
            return [fn1(t)f_{n-1}(t), fn2(t)f_{n-2}(t) ,,f0(t),,...,f_{0}(t), gn1(t),,gi(t)g_{n-1}(t),...,g_{i}(t), 𝝀i(t)fi(t)𝒘-\bm{\lambda}_{i}(t)^{\top}\frac{\partial{f_{i}(t)}}{\partial{{\bm{w}}}}]
        [L𝒉(iτ),L𝒘][\frac{\partial{L}}{\partial{{\bm{h}}(i\cdot{\tau})}},\frac{\partial{L}}{\partial{{\bm{w}}}}]=ODESolve(s0s_{0}, aug¯{\underline{~{}}}dynamics, τ{\tau}, 0, 𝒘{\bm{w}})
return L𝒉(0),L𝒘\frac{\partial{L}}{\partial{{\bm{h}}(0)}},\frac{\partial{L}}{\partial{{\bm{w}}}}

In the traditional framework of the NODEs, we can calculate the gradients of the loss function and recompute the hidden states by solving another augmented ODEs in a reversal time duration. However, to achieve the reverse-mode of the NDDEs in Algorithm 1, we need to store the checkpoints of the forward hidden states h(iτ)h(i\cdot\tau) for i=0,1,,ni=0,1,...,n, which, together with the adjoint 𝝀(t)\bm{\lambda}(t), can help us to recompute h(t)h(t) backwards in every time periods. The main idea of the Algorithm 1 is to convert the DDEs as a piece-wise ODEs such that one can naturally employ the framework of the NODEs to solve it. The complexity of Algorithm 1 is analyzed in Appendix.

4 Illustrative Experiments

4.1 Experiments on synthetic datasets

Here, we use some synthetic datasets produced by typical examples to compare the performance of the NODES and the NDDEs. In (Dupont et al., 2019), it is proved that the NODEs cannot represent the function g:dg:\mathbb{R}^{d}\rightarrow\mathbb{R}, defined by

g(𝒙)={1,if𝒙r1,1,ifr2𝒙r3,g({\bm{x}})=\left\{\begin{array}[]{ll}1,&\mbox{if}~{}\|{\bm{x}}\|\leq r_{1},\\ -1,&\mbox{if}~{}r_{2}\leq\|{\bm{x}}\|\leq r_{3},\end{array}\right.

where 0<r1<r2<r30<r_{1}<r_{2}<r_{3} and \|\cdot\| is the Euclidean norm. The following proposition show that the NDDEs have stronger capability of representation.

Proposition 1

The NDDEs can represent the function g(𝐱)g({\bm{x}}) specified above.

To validate this proposition, we construct a special form of the NDDEs by

{d𝒉i(t)dt=𝒉tτr,t>=0andi=1,d𝒉i(t)dt=0,t>=0andi=2,,d,𝒉(t)=𝒙,t<=0.\left\{\begin{array}[]{ll}\frac{d{{\bm{h}}_{i}(t)}}{dt}=\|{\bm{h}}_{t-\tau}\|-r,&t>=0~{}\mbox{and}~{}i=1,\\ \frac{d{{\bm{h}}_{i}(t)}}{dt}=0,&t>=0~{}\mbox{and}~{}i=2,...,d,\\ {\bm{h}}(t)={\bm{x}},&t<=0.\end{array}\right. (6)

where r:=(r1+r2)/2r:=(r_{1}+r_{2})/2 is a constant and the final time point TT is supposed to be equal to the time delay τ\tau with some sufficient large value. Under such configurations, we can linearly separate the two clusters by some hyper plane.

Refer to caption
Figure 3: (Left) The data at the time t=0t=0 and (Right) the transformed data at a sufficient large final time TT of the DDEs (6)(\ref{sep_2d_eq}). Here, the transformed data are linearly separable.

In Fig. 3, we, respectively, show the original data of g(𝒙)g({\bm{x}}) for the dimension d=2d=2 and the transformed data by the DDEs (6)(\ref{sep_2d_eq}) with the parameters r1=1r_{1}=1, r2=2r_{2}=2, r3=3r_{3}=3, T=10T=10, and τ=10\tau=10. Clearly, the transformed data by the DDEs are linearly separable. We also train the NDDEs to represent the g(𝒙)g({\bm{x}}) for d=2d=2, whose evolutions during the training procedure are, respectively, shown in Fig. 4. This figure also includes the evolution of the NODEs. Notably, while the NODEs is struggled to break apart the annulus, the NDDEs easily separate them. The training losses and the flows of the NODEs and the NDDEs are depicted, respectively, in Fig. 5. Particularly, the NDDEs achieve lower losses with the faster speed and directly separate the two clusters in the original 22-D space; however, the NODEs achieve it only by increasing the dimension of the data and separating them in a higher-dimensional space.

Refer to caption
Figure 4: Evolutions of the NDDEs (top) and the NODEs (bottom) in the feature space during the training procedure. Here, the evolution of the NODEs is directly produced by the code provided in (Dupont et al., 2019).
Refer to caption
Figure 5: Presented are the training losses (a) of the NODEs and the NDDEs on fitting the function g(x)g(x) for d=2d=2. Also presented are the flows, from the data at the initial time point (b), of the NODEs (d) and the NDDEs (c) after training. The flow of the NODEs is generated by the code provided in (Dupont et al., 2019).

In general, we have the following theoretical result for the NDDEs, whose proof is provided in Appendix.

Theorem 2

(Universal approximating capability of the NDDEs). For any given continuous function F:nnF:\mathbb{R}^{n}\rightarrow\mathbb{R}^{n}, if one can construct a neural network for approximating the map G(𝐱)=1T[F(𝐱)𝐱]G({\bm{x}})=\frac{1}{T}[F({\bm{x}})-{\bm{x}}], then there exists an NDDE of nn-dimension that can model the map 𝐱F(𝐱){\bm{x}}\mapsto F({\bm{x}}), that is, h(T)=F(𝐱)h(T)=F({\bm{x}}) with the initial function ϕ(t)=𝐱\phi(t)={\bm{x}} for t0t\leq 0.

Additionally, NDDEs are suitable for fitting the time series with the delay effect in the original systems, which cannot be easily achieved by using the NODEs. To illustrate this, we use a model of 22-D DDEs, written as 𝒙˙=𝑨tanh(𝒙(t)+𝒙(tτ))\dot{{\bm{x}}}={\bm{A}}\tanh({\bm{x}}(t)+{\bm{x}}(t-\tau)) with 𝒙(t)=𝒙0{\bm{x}}(t)={{\bm{x}}}_{0} for t<0t<0. Given the time series generated by the system, we use the NDDEs and the NODEs to fit it, respectively. Figure 6 shows that the NNDEs approach a much lower loss, compared to the NODEs. More interestingly, the NODEs prefer to fit the dimension of 𝒙2{{\bm{x}}}_{2} and its loss always sustains at a larger value, e.g. 0.250.25 in Figure 6. The main reason is that two different trajectories generated by the autonomous ODEs cannot intersect with each other in the phase space, due to the uniqueness of the solution of ODEs.

Refer to caption
Figure 6: Comparison of the NDDEs (top) versus the NODEs (bottom) in the fitting a 2-D time series with the delay effect in the original system. From the left to the right, the true and the fitted time series, the true and the fitted trajectories in the phase spaces, the dynamics of the parameters in the neural networks, and the dynamics of the losses during the training processes.

We perform experiments on another two classical DDEs, i.e., the population dynamics and the Mackey-Glass system (Erneux, 2009). Specifically, the equation of the dimensionless population dynamics is x˙=rx(t)(1x(tτ))\dot{x}=rx(t)(1-x(t-\tau)), where x(t)x(t) is the ratio of the population to the carrying capacity of the population, rr is the growth rate and τ\tau is the time delay. The Mackey-Glass system is written as x˙=βx(tτ)1+xn(tτ)γx(t)\dot{x}=\beta\frac{x(t-\tau)}{1+x^{n}(t-\tau)}-\gamma x(t), where x(t)x(t) is the number of the blood cells, β,n,τ,γ\beta,n,\tau,\gamma are the parameters of biological significance. The NODEs and the NDDEs are tested on these two dynamics. As shown in Figure 7, a very low training loss is achieved for the NDDEs while the the loss of the NODEs does not go down afterwards, always sustaining at some larger value. As for the predicting durations, the NDDEs thereby achieve a better performance than the NODEs. The details of the training could be found in Appendix.

Refer to caption
Figure 7: xThe training losses and the test losses of the population dynamics (top) and the Mackey-Glass system (bottom) by using the NDDEs, the NODEs and the ANODEs (where the augmented dimension equals to 11). The first column in the figures is the training losses. The figures from the second column to the fourth column present the test losses over the time intervals of the length τ\tau, 2τ2\tau, 5τ5\tau. The delays for the two DDEs are both designed as 1, respectively. The other parameters are set as r=1.8r=1.8, β=4.0\beta=4.0, n=9.65n=9.65, and γ=2\gamma=2. x

4.2 Experiments on image datasets

For the image datasets, we not only use the NODEs and the NDDEs but also an extension of the NDDEs, called the NODE+NDDE, which treats the initial function as an ODE. In our experiments, such a model exhibits the best performance, revealing strong capabilities in modelling and feature representations. Moreover, inspired by the idea of the augmented NODEs (Dupont et al., 2019), we extend the NDDEs and the NODE+NDDE to the A+NDDE and the A+NODE+NDDE, respectively. Precisely, for the augmented models, we augment the original image space to a higher-dimensional space, i.e., c×h×w(c+p)×h×w\mathbb{R}^{c\times h\times w}\rightarrow\mathbb{R}^{(c+p)\times h\times w}, where cc, hh, ww, and pp are, respectively, the number of channels, height, width of the image, and the augmented dimension. With such configurations of the same augmented dimension and approximately the same number of the model parameters, comparison studies on the image datasets using different models are reasonable. For the NODEs, we model the vector filed f(𝒉(t))f({\bm{h}}(t)) as the convolutional architectures together with a slightly different hyperparameter setups in (Dupont et al., 2019). The initial hidden state is set as 𝒉(0)c×h×w{\bm{h}}(0)\in\mathbb{R}^{c\times h\times w} with respect to an image. For the NDDEs, we design the vector filed as f(concat(𝒉(t),𝒉(tτ)))f({\rm concat}({\bm{h}}(t),{\bm{h}}(t-\tau))), mapping the space from 2c×h×w\mathbb{R}^{2c\times h\times w} to c×h×w\mathbb{R}^{c\times h\times w}, where concat(,){\rm concat}(\cdot,\cdot) executes the concatenation of two tensors on the channel dimension. Its initial function is designed as a constant function, i.e., h(t)h(t) is identical to the input/image for t<0t<0. For the NODE+NDDE, we model the initial function as an ODE, which follows the same model structure of the NODEs. For the augmented models, the augmented dimension is chosen from the set {1, 2, 4}. Moreover, the training details could be found in Appendix, including the training setting and the number of function evaluations for each model on the image datasets.

The training processes on MNIST, CIFAR10, and SVHN are shown in Fig. 8. Overall, the NDDEs and its extensions have their training losses decreasing faster than the NODEs/ANODEs which achieve lower training and test loss. Also the test accuracies are much higher than the that of the NODEs/ANODEs (refer to Tab. 1). Naturally, the better performance of the NDDEs is attributed to the integration of the information not only on the hidden states at the current time tt but at the previous time tτt-\tau. This kind of framework is akin to the key idea proposed in (Huang et al., 2017), where the information is processed on many hidden states. Here, we run all the experiments for 5 times independently.

Refer to caption
Figure 8: The training loss (left column), the test loss (middle column), and the accuracy (right column) over 5 realizations for the three image sets, i.e., CIFAR10 (top row), MNIST (middle row), and SVHN (bottom row).
CIFAR10 MNIST SVHN
NODE 53.92%±0.6753.92\%\pm 0.67 96.21%±0.6696.21\%\pm 0.66 80.66%±0.5680.66\%\pm 0.56
NDDE 55.69%±0.3955.69\%\pm 0.39 96.22%±0.5596.22\%\pm 0.55 81.49%±0.0981.49\%\pm 0.09
NODE+NDDE 55.89%±0.71{\bf 55.89\%\pm 0.71} 97.26%±0.22{\bf 97.26\%\pm 0.22} 82.60%±0.22{\bf 82.60\%\pm 0.22}
A1+NIDE 56.14%±0.4856.14\%\pm 0.48 97.89%±0.1497.89\%\pm 0.14 81.17%±0.2981.17\%\pm 0.29
A1+NDDE 56.83%±0.6056.83\%\pm 0.60 97.83%±0.0797.83\%\pm 0.07 82.46%±0.2882.46\%\pm 0.28
A1+NODE+NDDE 57.31%±0.61{\bf 57.31\%\pm 0.61} 98.16%±0.07{\bf 98.16\%\pm 0.07} 83.02%±0.37{\bf 83.02\%\pm 0.37}
A2+NODE 57.27%±0.4657.27\%\pm 0.46 98.25%±0.0898.25\%\pm 0.08 81.73%±0.9281.73\%\pm 0.92
A2+NDDE 58.13%±0.3258.13\%\pm 0.32 98.22%±0.0498.22\%\pm 0.04 82.43%±0.2682.43\%\pm 0.26
A2+NODE+NDDE 58.40%±0.31{\bf 58.40\%\pm 0.31} 98.26%±0.06{\bf 98.26\%\pm 0.06} 83.73%±0.72{\bf 83.73\%\pm 0.72}
A4+NODE 58.93%±0.3358.93\%\pm 0.33 98.33%±0.1298.33\%\pm 0.12 82.72%±0.6082.72\%\pm 0.60
A4+NDDE 59.35%±0.4859.35\%\pm 0.48 98.31%±0.0398.31\%\pm 0.03 82.87%±0.5582.87\%\pm 0.55
A4+NODE+NDDE 59.94%±0.66{\bf 59.94\%\pm 0.66} 98.52%±0.11{\bf 98.52\%\pm 0.11} 83.62%±0.51{\bf 83.62\%\pm 0.51}
Table 1: The test accuracies with their standard deviations over 5 realizations on the three image datasets. In the first column, pp (=1, 2, or 4) in App means the number of the channels of zeros into the input image during the augmentation of the image space c×h×w(c+p)×h×w\mathbb{R}^{c\times h\times w}\rightarrow\mathbb{R}^{(c+p)\times h\times w} (Dupont et al., 2019). For each model, the initial (resp. final) time is set as 0 (resp. 1), and the delays of the NDDEs and its extensions are all set as 1, simply equal to the final time.

5 Discussion

In this section, we present the limitations of the NDDEs and further suggest several potential directions for future works. We add the delay effect to the NDDEs, which renders the model absolutely irreversible. Algorithm 1 thus requires a storage of the checkpoints of the hidden state 𝒉(t){\bm{h}}(t) at every instant of the multiple of τ\tau. Actually, solving the DDEs is transformed to solving the ODEs of an increasingly high dimension with respect to the ratio of the final time TT and the time delay τ\tau. This definitely indicates a high computational cost. To further apply and improve the framework of the NDDEs, a few potential directions for future works are suggested, including:

Applications to more real-world datasets. In the real-world systems such as physical, chemical, biological, and ecological systems, the delay effects are inevitably omnipresent, truly affecting the dynamics of the produced time-series (Bocharov & Rihan, 2000; Kajiwara et al., 2012). The NDDEs are undoubtedly suitable for realizing model-free and accurate prediction (Quaglino et al., 2019). Additionally, since the NODEs have been generalized to the areas of Computer Vision and Natural Language Processing He et al. (2019); Yang et al. (2019); Liu et al. (2020), the framework of the NDDEs probably can be applied to the analogous areas, where the delay effects should be ubiquitous in those streaming data.

Extension of the NDDEs. A single constant time-delay in the NDDEs can be further generalized to the case of multiple or/and distributed time delays (Shampine & Thompson, 2001). As such, the model is likely to have much stronger capability to extract the feature, because the model leverages the information at different time points to make the decision in time. All these extensions could be potentially suitable for some complex tasks. However, such complex model may require tremendously huge computational cost.x

Time-dependent controllers. From a viewpoint of control theory, the parameters in the NODEs/NDDEs could be regarded as time-independent controllers, viz. constant controllers. A natural generalization way is to model the parameters as time-dependent controllers. In fact, such controllers were proposed in (Zhang et al., 2019b), where the parameters 𝒘(t){\bm{w}}(t) were treated as another learnable ODE 𝒘˙=q(𝒘(t),𝒑)\dot{{\bm{w}}}=q({\bm{w}}(t),{\bm{p}}), q(,)q(\cdot,\cdot) is a different neural network, and the parameters 𝒑{\bm{p}} and the initial state 𝒘(0){\bm{w}}(0) are pending for optimization. Also, the idea of using a neural network to generate the other one was initially conceived in some earlier works including the study of the hypernetworks (Ha et al., 2016).

6 Conclusion

In this article, we establish the framework of NDDEs, whose vector fields are determined mainly by the states at the previous time. We employ the adjoint sensitivity method to compute the gradients of the loss function. The obtained adjoint dynamics backward follow another DDEs coupled with the forward hidden states. We show that the NDDEs can represent some typical functions that cannot be represented by the original framework of NODEs. Moreover, we have validated analytically that the NDDEs possess universal approximating capability. We also demonstrate the exceptional efficacy of the proposed framework by using the synthetic data or real-world datasets. All these reveal that integrating the elements of dynamical systems to the architecture of neural networks could be potentially beneficial to the promotion of network performance.

Author Contributions

WL conceived the idea, QZ, YG & WL performed the research, QZ & YG performed the mathematical arguments, QZ analyzed the data, and QZ & WL wrote the paper.

Acknowledgments

WL was supported by the National Key R&D Program of China (Grant no. 2018YFC0116600), the National Natural Science Foundation of China (Grant no. 11925103), and by the STCSM (Grant No. 18DZ1201000, 19511101404, 19511132000).

References

  • Bocharov & Rihan (2000) Gennadii A Bocharov and Fathalla A Rihan. Numerical modelling in biosciences using delay differential equations. Journal of Computational and Applied Mathematics, 125(1-2):183–199, 2000.
  • Chang et al. (2017) Bo Chang, Lili Meng, Eldad Haber, Frederick Tung, and David Begert. Multi-level residual networks from dynamical systems view. arXiv preprint arXiv:1710.10348, 2017.
  • Chang et al. (2019) Bo Chang, Minmin Chen, Eldad Haber, and Ed H Chi. Antisymmetricrnn: A dynamical system view on recurrent neural networks. arXiv preprint arXiv:1902.09689, 2019.
  • Chen et al. (2018) Ricky TQ Chen, Yulia Rubanova, Jesse Bettencourt, and David K Duvenaud. Neural ordinary differential equations. In Advances in neural information processing systems, pp. 6571–6583, 2018.
  • Dupont et al. (2019) Emilien Dupont, Arnaud Doucet, and Yee Whye Teh. Augmented neural odes. In Advances in Neural Information Processing Systems, pp. 3140–3150, 2019.
  • E (2017) Weinan E. A proposal on machine learning via dynamical systems. Communications in Mathematics and Statistics, 5(1):1–11, 2017.
  • E et al. (2019) Weinan E, Jiequn Han, and Qianxiao Li. A mean-field optimal control formulation of deep learning. Research in the Mathematical Sciences, 6(1):10, 2019.
  • Elman (1990) Jeffrey L Elman. Finding structure in time. Cognitive science, 14(2):179–211, 1990.
  • Erneux (2009) Thomas Erneux. Applied delay differential equations, volume 3. Springer Science & Business Media, 2009.
  • Fang et al. (2018) Leheng Fang, Wei Lin, and Qiang Luo. Brain-inspired constructive learning algorithms with evolutionally additive nonlinear neurons. International Journal of Bifurcation and Chaos, 28(05):1850068–, 2018.
  • Ha et al. (2016) David Ha, Andrew Dai, and Quoc V Le. Hypernetworks. arXiv preprint arXiv:1609.09106, 2016.
  • Haber & Ruthotto (2017) Eldad Haber and Lars Ruthotto. Stable architectures for deep neural networks. Inverse Problems, 34(1):014004, 2017.
  • Han et al. (2018) Jiequn Han, Arnulf Jentzen, and E Weinan. Solving high-dimensional partial differential equations using deep learning. Proceedings of the National Academy of Sciences, 115(34):8505–8510, 2018.
  • He et al. (2016) Kaiming He, Xiangyu Zhang, Shaoqing Ren, and Jian Sun. Deep residual learning for image recognition. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp.  770–778, 2016.
  • He et al. (2019) Xiangyu He, Zitao Mo, Peisong Wang, Yang Liu, Mingyuan Yang, and Jian Cheng. Ode-inspired network design for single image super-resolution. In Proceedings of the IEEE Conference on Computer Vision and Pattern Recognition, pp.  1732–1741, 2019.
  • Huang et al. (2017) Gao Huang, Zhuang Liu, Laurens Van Der Maaten, and Kilian Q Weinberger. Densely connected convolutional networks. In Proceedings of the IEEE conference on computer vision and pattern recognition, pp.  4700–4708, 2017.
  • Kajiwara et al. (2012) Tsuyoshi Kajiwara, Toru Sasaki, and Yasuhiro Takeuchi. Construction of lyapunov functionals for delay differential equations in virology and epidemiology. Nonlinear Analysis: Real World Applications, 13(4):1802–1826, 2012.
  • Lan et al. (2019) Zhenzhong Lan, Mingda Chen, Sebastian Goodman, Kevin Gimpel, Piyush Sharma, and Radu Soricut. Albert: A lite bert for self-supervised learning of language representations. arXiv preprint arXiv:1909.11942, 2019.
  • Li & Hao (2018) Qianxiao Li and Shuji Hao. An optimal control approach to deep learning and applications to discrete-weight neural networks. arXiv preprint arXiv:1803.01299, 2018.
  • Li et al. (2017) Qianxiao Li, Long Chen, Cheng Tai, and E Weinan. Maximum principle based algorithms for deep learning. The Journal of Machine Learning Research, 18(1):5998–6026, 2017.
  • Liberzon (2011) Daniel Liberzon. Calculus of variations and optimal control theory: a concise introduction. Princeton University Press, 2011.
  • Liu et al. (2019) Xuanqing Liu, Tesi Xiao, Si Si, Qin Cao, Sanjiv Kumar, and Cho-Jui Hsieh. Neural sde: Stabilizing neural ode networks with stochastic noise. arXiv preprint arXiv:1906.02355, 2019.
  • Liu et al. (2020) Xuanqing Liu, Hsiang-Fu Yu, Inderjit Dhillon, and Cho-Jui Hsieh. Learning to encode position for transformer with continuous dynamical model. arXiv preprint arXiv:2003.09229, 2020.
  • Long et al. (2018) Zichao Long, Yiping Lu, Xianzhong Ma, and Bin Dong. Pde-net: Learning pdes from data. In International Conference on Machine Learning, pp. 3208–3216, 2018.
  • Long et al. (2019) Zichao Long, Yiping Lu, and Bin Dong. Pde-net 2.0: Learning pdes from data with a numeric-symbolic hybrid deep network. Journal of Computational Physics, 399:108925, 2019.
  • Lu et al. (2018) Yiping Lu, Aoxiao Zhong, Quanzheng Li, and Bin Dong. Beyond finite layer neural networks: Bridging deep architectures and numerical differential equations. In International Conference on Machine Learning, pp. 3276–3285. PMLR, 2018.
  • Pathak et al. (2018) Jaideep Pathak, Brian Hunt, Michelle Girvan, Zhixin Lu, and Edward Ott. Model-free prediction of large spatiotemporally chaotic systems from data: A reservoir computing approach. Physical Review Letters, 120(2), 2018.
  • Pontryagin et al. (1962) LS Pontryagin, VG Boltyanskij, RV Gamkrelidze, and EF Mishchenko. The mathematical theory of optimal processes. 1962.
  • Quaglino et al. (2019) Alessio Quaglino, Marco Gallieri, Jonathan Masci, and Jan Koutník. Snode: Spectral discretization of neural odes for system identification. arXiv preprint arXiv:1906.07038, 2019.
  • Rumelhart et al. (1986) David E Rumelhart, Geoffrey E Hinton, and Ronald J Williams. Learning representations by back-propagating errors. nature, 323(6088):533–536, 1986.
  • Ruthotto & Haber (2019) Lars Ruthotto and Eldad Haber. Deep neural networks motivated by partial differential equations. Journal of Mathematical Imaging and Vision, pp.  1–13, 2019.
  • Shampine & Thompson (2001) Lawrence F Shampine and Skip Thompson. Solving ddes in matlab. Applied Numerical Mathematics, 37(4):441–458, 2001.
  • Sun et al. (2018) Qi Sun, Yunzhe Tao, and Qiang Du. Stochastic training of residual networks: a differential equation viewpoint. arXiv preprint arXiv:1812.00174, 2018.
  • Sun et al. (2020) Yifan Sun, Linan Zhang, and Hayden Schaeffer. Neupde: Neural network based ordinary and partial differential equations for modeling time-dependent data. In Mathematical and Scientific Machine Learning, pp. 352–372. PMLR, 2020.
  • Tang et al. (2020) Yang Tang, Jürgen Kurths, Wei Lin, Edward Ott, and Ljupco Kocarev. Introduction to focus issue: When machine learning meets complex systems: Networks, chaos, and nonlinear dynamics. Chaos: An Interdisciplinary Journal of Nonlinear Science, 30(6):063151, 2020.
  • Yang et al. (2019) Guandao Yang, Xun Huang, Zekun Hao, Ming-Yu Liu, Serge Belongie, and Bharath Hariharan. Pointflow: 3d point cloud generation with continuous normalizing flows. In Proceedings of the IEEE International Conference on Computer Vision, pp.  4541–4550, 2019.
  • Zhang et al. (2019a) Dinghuai Zhang, Tianyuan Zhang, Yiping Lu, Zhanxing Zhu, and Bin Dong. You only propagate once: Painless adversarial training using maximal principle. arXiv preprint arXiv:1905.00877, 2(3), 2019a.
  • Zhang et al. (2019b) Tianjun Zhang, Zhewei Yao, Amir Gholami, Joseph E Gonzalez, Kurt Keutzer, Michael W Mahoney, and George Biros. Anodev2: A coupled neural ode framework. In Advances in Neural Information Processing Systems, pp. 5151–5161, 2019b.
  • Zhu et al. (2019) Qunxi Zhu, Huanfei Ma, and Wei Lin. Detecting unstable periodic orbits based only on time series: When adaptive delayed feedback control meets reservoir computing. Chaos, 29(9):93125–93125, 2019.

Appendix A Appendix

A.1 The First Proof of Theorem 1

Here, we present a direct proof of the adjoint method for the NDDEs. For the neat of the proof, the following notations are slightly different from those in the main text.

Let x(t)x(t) obey the DDE written as

{x˙(t)=f(x(t),y(t),θ(t)),y(t)=x(tτ),t[0,T],x(t)=x0,t[τ,0].\left\{\begin{aligned} \dot{x}(t)&=f(x(t),y(t),\theta(t)),~{}y(t)=x(t-\tau),~{}t\in[0,T],\\ x(t)&=x_{0},~{}t\in[-\tau,0].\end{aligned}\right. (7)

whose adjoint state is defined as

λ(t):=Lx(t),\lambda(t):=\frac{\partial{L}}{\partial{x(t)}}, (8)

where LL is the loss function, that is, L:=L(X(T))L:=L(X(T)). After discretizing the above DDE, we have

x(t+Δt)\displaystyle{x}(t+\Delta t) =x(t)+Δtf(x(t),y(t),θ(t)),\displaystyle=x(t)+\Delta t\cdot f(x(t),y(t),\theta(t)), (9)
=x(t)+Δtf(x(t),x(tτ),θ(t)),\displaystyle={x(t)}+\Delta t\cdot f({x(t)},x(t-\tau),\theta(t)),
x(t+τ+Δt)\displaystyle{x}(t+\tau+\Delta t) =x(t+τ)+Δtf(x(t+τ),y(t+τ),θ(t+τ)),\displaystyle=x(t+\tau)+\Delta t\cdot f(x(t+\tau),y(t+\tau),\theta(t+\tau)),
=x(t+τ)+Δtf(x(t+τ),x(t),θ(t+τ)).\displaystyle=x(t+\tau)+\Delta t\cdot f(x(t+\tau),{x(t)},\theta(t+\tau)).

According to the definition of λ(t)\lambda(t) and applying the chain rule, we have

λ(t)\displaystyle\lambda(t) =Lx(t+Δt)x(t+Δt)x(t)+Lx(t+τ+Δt)x(t+τ+Δt)x(t)χ[0,Tτ](t)\displaystyle=\frac{\partial{L}}{\partial{x(t+\Delta t)}}\frac{\partial{x(t+\Delta t)}}{\partial{x(t)}}+\frac{\partial{L}}{\partial{x(t+\tau+\Delta t)}}\frac{\partial{x(t+\tau+\Delta t)}}{\partial{x(t)}}\cdot\chi_{[0,T-\tau]}(t) (10)
=λ(t+Δt)x(t+Δt)x(t)+λ(t+τ+Δt)x(t+τ+Δt)x(t)χ[0,Tτ](t)\displaystyle=\lambda(t+\Delta t)\frac{\partial{x(t+\Delta t)}}{\partial{x(t)}}+\lambda(t+\tau+\Delta t)\frac{\partial{x(t+\tau+\Delta t)}}{\partial{x(t)}}\cdot\chi_{[0,T-\tau]}(t)
=λ(t+Δt)(I+Δtfx(x(t),y(t),θ(t)))\displaystyle=\lambda(t+\Delta t)(I+\Delta t\cdot f_{x}(x(t),y(t),\theta(t)))
+λ(t+τ+Δt)Δtfy(x(t+τ),y(t+τ),θ(t+τ)))χ[0,Tτ](t)\displaystyle~{}~{}~{}~{}+\lambda(t+\tau+\Delta t)\Delta t\cdot f_{y}(x(t+\tau),y(t+\tau),\theta(t+\tau)))\cdot\chi_{[0,T-\tau]}(t)
=λ(t+Δt)+Δt[λ(t+Δt)fx(t)+λ(t+τ+Δt)fy(t+τ)χ[0,Tτ](t)]\displaystyle=\lambda(t+\Delta t)+\Delta t\cdot\left[\lambda(t+\Delta t)\cdot f_{x}(t)+\lambda(t+\tau+\Delta t)\cdot f_{y}(t+\tau)\cdot\chi_{[0,T-\tau]}(t)\right]

which implies,

λ˙(t)\displaystyle\dot{\lambda}(t) =limΔt0λ(t+Δt)λ(t)Δt\displaystyle=\lim_{\Delta t\rightarrow 0}\frac{\lambda(t+\Delta t)-\lambda(t)}{\Delta t} (11)
=λ(t)fx(t)λ(t+τ)fy(t+τ)χ[0,Tτ](t),\displaystyle=-\lambda(t)\cdot f_{x}(t)-\lambda(t+\tau)\cdot f_{y}(t+\tau)\cdot\chi_{[0,T-\tau]}(t),

where χ[0,Tτ]()\chi_{[0,T-\tau]}(\cdot) is a characteristic function. For the parameter θ(t)\theta(t), the result can be analogously derived as

Lθ(t)\displaystyle\frac{\partial{L}}{\partial{\theta(t)}} =Lx(t+Δt)x(t+Δt)θ(t)\displaystyle=\frac{\partial{L}}{\partial{x(t+\Delta t)}}\frac{\partial{x(t+\Delta t)}}{\partial{\theta(t)}} (12)
=Δtλ(t+Δt)fθ(t)\displaystyle=\Delta t\cdot\lambda(t+\Delta t)\cdot f_{\theta}(t)

In this article, θ(t)\theta(t) is considered to be a constant variable, i.e., θ(t)θ\theta(t)\equiv\theta, which yields:

Lθ\displaystyle\frac{\partial{L}}{\partial{\theta}} =limΔt0Δtλ(t+Δt)fθ(t)\displaystyle=\lim_{\Delta t\rightarrow 0}\sum\Delta t\cdot\lambda(t+\Delta t)\cdot f_{\theta}(t) (13)
=0Tλ(t)fθ(t)𝑑t\displaystyle=\int_{0}^{T}\lambda(t)\cdot f_{\theta}(t)dt
=T0λ(t)fθ(t)dt.\displaystyle=\int_{T}^{0}-\lambda(t)\cdot f_{\theta}(t)dt.

To summarize, we get the gradients with respect to x(0)x(0) and θ\theta in a form of augmented DDEs. These DDEs are backward in time and written in an integral form of

x(0)\displaystyle x(0) =x(T)+T0f(x,y,θ)𝑑t,\displaystyle=x(T)+\int_{T}^{0}f(x,y,\theta)dt, (14)
Lx(0)\displaystyle\frac{\partial{L}}{\partial{x(0)}} =Lx(T)+T0λ(t)fx(t)λ(t+τ)fy(t+τ)χ[0,Tτ](t)dt,\displaystyle=\frac{\partial{L}}{\partial{x(T)}}+\int_{T}^{0}-\lambda(t)\cdot f_{x}(t)-\lambda(t+\tau)\cdot f_{y}(t+\tau)\cdot\chi_{[0,T-\tau]}(t)dt,
Lθ\displaystyle\frac{\partial{L}}{\partial{\theta}} =T0λ(t)fθ(t)dt.\displaystyle=\int_{T}^{0}-\lambda(t)\cdot f_{\theta}(t)dt.

A.2 The Second Proof of Theorem 1

Here, we mainly employ the Lagrangian multiplier method and the calculus of variation to derive the adjoint method for the NDDEs. First, we define the Lagrangian by

:=L(X(T))+0Tλ(t)(x˙f(x(t),y(t),θ))𝑑t.\mathcal{L}:=L(X(T))+\int_{0}^{T}\lambda(t)(\dot{x}-f(x(t),y(t),\theta))dt.\\ (15)

We thereby need to find the so-called Karush-Kuhn-Tucker (KKT) conditions for the Lagrangian, which is necessary for finding the optimal solution of θ\theta. To obtain the KKT conditions, the calculus of variation is applied by taking variations with respect to λ(t)\lambda(t) and x(t)x(t).

For λ(t)\lambda(t), let λ^(t)\hat{\lambda}(t) be a continuous and differentiable function with a scalar ϵ\epsilon. We add the perturbation λ^(t)\hat{\lambda}(t) to the Lagrangian \mathcal{L}, which results in a new Lagrangian, denoted by

(ϵ):=L(x(T))+0T(λ(t)+ϵλ^(t))(x˙f(x(t),y(t),θ))𝑑t.\mathcal{L}(\epsilon):=L(x(T))+\int_{0}^{T}(\lambda(t)+\epsilon\hat{\lambda}(t))(\dot{x}-f(x(t),y(t),\theta))dt. (16)

In order to obey the optimal condition for λ(t)\lambda(t), we require the following equation

d(ϵ)dϵ=0Tλ^(t)(x˙f(x(t),y(t),θ))𝑑t\frac{d\mathcal{L}(\epsilon)}{d\epsilon}=\int_{0}^{T}\hat{\lambda}(t)(\dot{x}-f(x(t),y(t),\theta))dt (17)

to be zero. Due to the arbitrariness of λ^(t)\hat{\lambda}(t), we obtain

x˙f(x(t),y(t),θ)=0,t[0,T],\dot{x}-f(x(t),y(t),\theta)=0,~{}~{}\forall t\in[0,T], (18)

which is exactly the DDE forward in time.

Analogously, we can take variation with respect to x(t)x(t) and let x^(t)\hat{x}(t) be a continuous and differentiable function with a scalar ϵ\epsilon. Here, x^(t)=0\hat{x}(t)=0 for t[τ,0]t\in[-\tau,0]. We also denote by y^(t):=x^(tτ)\hat{y}(t):=\hat{x}(t-\tau) for t[0,T]t\in[0,T]. The new Lagrangian under the perturbation of x^(t)\hat{x}(t) becomes

(ϵ):=L(x(T)+ϵx^(T))+0Tλ(t)(dx(t)+ϵx^(t)dtf(x(t)+ϵx^(t),y(t)+ϵy^(t),θ))𝑑t.\mathcal{L}(\epsilon):=L(x(T)+\epsilon\hat{x}(T))+\int_{0}^{T}\lambda(t)\left(\frac{d{x(t)+\epsilon\hat{x}(t)}}{dt}-f(x(t)+\epsilon\hat{x}(t),y(t)+\epsilon\hat{y}(t),\theta)\right)dt.\\ (19)

We then compute the d(ϵ)dϵ\frac{d\mathcal{L}(\epsilon)}{d\epsilon}, which gives

d(ϵ)dϵ|ϵ=0=Lx(T)x^(T)+0Tλ(t)(dx^(t)dtfx(x(t),y(t),θ)x^(t)fy(x(t),y(t),θ)y^(t))𝑑t\displaystyle\frac{d\mathcal{L}(\epsilon)}{d\epsilon}|_{\epsilon=0}=\frac{\partial L}{\partial x(T)}\hat{x}(T)+\int_{0}^{T}{{\lambda}(t)}\left({\frac{d\hat{x}(t)}{dt}}-f_{x}(x(t),y(t),\theta)\hat{x}(t)-f_{y}(x(t),y(t),\theta)\hat{y}(t)\right)dt
=Lx(T)x^(T)+λ(t)x^(t)|0T+0Tx^(t)dλ(t)dtintegration by parts\displaystyle=\frac{\partial L}{\partial x(T)}\hat{x}(T)+{\lambda(t)\hat{x}(t)|_{0}^{T}}+\int_{0}^{T}{-{\hat{x}(t)}\frac{d\lambda(t)}{dt}}~{}~{}~{}~{}~{}~{}~{}~{}~{}~{}~{}~{}~{}~{}\mbox{integration by parts}
+0Tλ(t)fx(x(t),y(t),θ)x^(t)λ(t)fy(x(t),y(t),θ)y^(t)dt\displaystyle~{}~{}~{}~{}+\int_{0}^{T}-\lambda(t)f_{x}(x(t),y(t),\theta)\hat{x}(t)-\lambda(t)f_{y}(x(t),y(t),\theta)\hat{y}(t)dt
=(Lx(T)+λ(T))x^(T)+0Tx^(t)dλ(t)dtλ(t)fx(x(t),y(t),θ)x^(t)\displaystyle=\left(\frac{\partial L}{\partial x(T)}+\lambda(T)\right)\hat{x}(T)+\int_{0}^{T}{-{\hat{x}(t)}\frac{d\lambda(t)}{dt}}-\lambda(t)f_{x}(x(t),y(t),\theta)\hat{x}(t)
0Tλ(t)fy(x(t),y(t),θ)x^(tτ)𝑑t\displaystyle~{}~{}~{}~{}-\int_{0}^{T}\lambda(t)f_{y}(x(t),y(t),\theta){\hat{x}(t-\tau)}dt
=(Lx(T)+λ(T))x^(T)+0Tx^(t)dλ(t)dtλ(t)fx(x(t),y(t),θ)x^(t)\displaystyle=\left(\frac{\partial L}{\partial x(T)}+\lambda(T)\right)\hat{x}(T)+\int_{0}^{T}{-{\hat{x}(t)}\frac{d\lambda(t)}{dt}}-\lambda(t)f_{x}(x(t),y(t),\theta)\hat{x}(t) (20)
τTτλ(t+τ)fy(x(t+τ),y(t+τ),θ)x^(t)𝑑t\displaystyle~{}~{}~{}~{}-\int_{-\tau}^{T-\tau}\lambda(t^{\prime}+\tau)f_{y}(x(t^{\prime}+\tau),y(t^{\prime}+\tau),\theta){\hat{x}(t^{\prime})}dt^{\prime}
=(Lx(T)+λ(T))x^(T)+0Tx^(t)dλ(t)dtλ(t)fx(x(t),y(t),θ)x^(t)\displaystyle=\left(\frac{\partial L}{\partial x(T)}+\lambda(T)\right)\hat{x}(T)+\int_{0}^{T}{-{\hat{x}(t)}\frac{d\lambda(t)}{dt}}-\lambda(t)f_{x}(x(t),y(t),\theta)\hat{x}(t)
0Tτλ(t)fy(x(t+τ),y(t+τ),θ)x^(t)𝑑tno variation on the interval [τ,0]\displaystyle~{}~{}~{}~{}-\int_{{0}}^{T-\tau}\lambda(t^{\prime})f_{y}(x(t^{\prime}+\tau),y(t^{\prime}+\tau),\theta){\hat{x}(t^{\prime})}dt^{\prime}~{}~{}~{}~{}~{}~{}~{}\mbox{no variation on the interval~{}}[-\tau,0]
=(Lx(T)+λ(T))x^(T)\displaystyle=\left(\frac{\partial L}{\partial x(T)}+\lambda(T)\right)\hat{x}(T)
+0Tx^(t)(dλ(t)dtλ(t)fx(x(t),y(t),θ)λ(t+τ)fy(x(t+τ),y(t+τ),θ)χ[0,Tτ](t))𝑑t\displaystyle~{}~{}~{}~{}+\int_{0}^{T}{\hat{x}(t)}\left(-\frac{d\lambda(t)}{dt}-\lambda(t)f_{x}(x(t),y(t),\theta)-\lambda(t+\tau)f_{y}(x(t+\tau),y(t+\tau),\theta){\chi_{[0,T-\tau]}(t)}\right)dt

Notice that d(ϵ)dϵ|ϵ=0=0\frac{d\mathcal{L}(\epsilon)}{d\epsilon}|_{\epsilon=0}=0 is satisfied for all continuous differentiable x^(t)\hat{x}(t) at the optimal x(t)x(t). Thus, we have

dλ(t)dt=λ(t)fx(x(t),y(t),θ)λ(t+τ)fy(x(t+τ),y(t+τ),θ)χ[0,Tτ](t),λ(T)=Lx(T).\displaystyle\frac{d\lambda(t)}{dt}=-\lambda(t)f_{x}(x(t),y(t),\theta)-\lambda(t+\tau)f_{y}(x(t+\tau),y(t+\tau),\theta){\chi_{[0,T-\tau]}(t)},~{}~{}\lambda(T)=\frac{\partial L}{\partial x(T)}. (21)

Therefore, the adjoint state follows a DDE as well.

A.3 The Proof of Theorem 2

The validation for Theorem 2 is straightforward. Consider the NDDEs in the following form:

{d𝒉tdt=f(𝒉tτ;𝒘),t>=0,𝒉(t)=𝒙,t<=0\left\{\begin{array}[]{ll}\frac{d{{\bm{h}}_{t}}}{dt}=f({\bm{h}}_{t-\tau};{\bm{w}}),&t>=0,\\ {\bm{h}}(t)={\bm{x}},&t<=0\end{array}\right.

where τ\tau equals to the final time TT. Due to 𝒉(t)=𝒙{\bm{h}}(t)={\bm{x}} for t0t\leq 0, then the vector field of the NDDEs in the interval [0,T][0,T] is constant. This implies 𝒉(T)=𝒙+Tf(𝒙;𝒘){\bm{h}}(T)={\bm{x}}+T\cdot f({\bm{x}};{\bm{w}}). Assume that the neural network f(𝒙;𝒘)f({\bm{x}};{\bm{w}}) is able to approximate the map G(𝒙)=1T[F(𝒙)𝒙]G({\bm{x}})=\frac{1}{T}[F({\bm{x}})-{\bm{x}}]. Then, we have 𝒉(T)=𝒙+T1T[F(𝒙)𝒙]=F(𝒙){\bm{h}}(T)={\bm{x}}+T\cdot\frac{1}{T}[F({\bm{x}})-{\bm{x}}]=F({\bm{x}}). The proof is completed.

A.4 Complexity Analysis of the Algorithm 1

As shown in (Chen et al., 2018), the memory and the time costs for solving the NODEs are 𝒪(1)\mathcal{O}(1) and 𝒪(L)\mathcal{O}(L), where LL is the number of the function evaluations in the time interval [0,T][0,T]. More precisely, solving the NODEs is memory efficient without storing any intermediate states of the evaluated time points in solving the NODEs. Here, we intend to analyze the complexity of Algorithm 1. It should be noting that the state-of-the-art for the DDE software is not as advanced as that for the ODE software. Hence, solving a DDE is much difficult compared with solving the ODE. There exists several DDE solvers, such as the popular solver, the dde23 provided by MATLAB. However, these DDE solvers usually need to store the history states to help the solvers access the past time state h(tτ)h(t-\tau). Hence, the memory cost of DDE solvers is 𝒪(H)\mathcal{O}(H), where HH is the number of the history states. This is the major difference between the DDEs and the ODEs, as solving the ODEs is memory efficient, i.e., 𝒪(1)\mathcal{O}(1). In Algorithm 1, we propose a piece-wise ODE solver to solve the DDEs. The underlying idea is to transform the DDEs into the piece-wise ODEs for every τ\tau time periods such that one can naturally employ the framework of the NODEs. More precisely, we compute the state at time kτk\tau by solving an augmented ODE with the augmented initial state, i.e., concatenating the states at time τ,0,τ,,(k1)τ-\tau,0,\tau,...,(k-1)\tau into a single vector. Such a method has several strengths and has weaknesses as well. The strengths include:

  • One can easily implement the algorithm using the framework of the NODEs, and

  • Algorithm 1 becomes quite memory efficient 𝒪(n)\mathcal{O}(n), where we only need to store a small number of the forward states, 𝒉(0),,𝒉(nτ){\bm{h}}(0),...,{\bm{h}}(n\tau), to help the algorithm compute the adjoint and the gradients in a reverse mode. Here, the final TT is assumed to be not very large compared with the time delay τ\tau, for example, T=nτT=n\tau with a small integer nn.

Notably, we chosen n=1n=1 (i.e., T=τ=1.0T=\tau=1.0) of the NDDEs in the experiments on the image datasets, resulting in a quite memory efficient computation. Additionally, the weaknesses involve:

  • Algorithm 1 may suffer from a high memory cost, if the final TT is extremely larger than the τ\tau (i.e., many forward states, 𝒉(0),,𝒉(nτ){\bm{h}}(0),...,{\bm{h}}(n\tau), are required to be stored), and

  • the increasing augmented dimension of the ODEs may lead to the heavy time cost for each evaluation in the ODE solver.

Appendix B Experimental Details

B.1 Synthetic datasets

For the classification of the dataset of concentric spheres, we almost follow the experimental configurations used in (Dupont et al., 2019). The dataset contain 2000 data points in the outer annulus and 1000 data points in the inner sphere. We choose r1=0.5r_{1}=0.5, r2=1.0r_{2}=1.0, and r3=1.5r_{3}=1.5. We solve the classification problem using the NODE and the NDDE, whose structures are described, respectively, as:

  1. 1.

    Structure of the NODEs: the vector field is modeled as

    f(𝒙)=WoutReLU(WReLU(Win𝒙)),f({\bm{x}})=W_{out}\mbox{ReLU}(W\mbox{ReLU}(W_{in}{\bm{x}})),

    where Win32×2W_{in}\in\mathbb{R}^{32\times 2}, W32×32W\in\mathbb{R}^{32\times 32}, and Wout2×32W_{out}\in\mathbb{R}^{2\times 32};

  2. 2.

    Structure of the NDDEs: the vector field is modeled as

    f(𝒙(tτ))=WoutReLU(WReLU(Win𝒙(tτ))),f({\bm{x}}(t-\tau))=W_{out}\mbox{ReLU}(W\mbox{ReLU}(W_{in}{\bm{x}}(t-\tau))),

    where Win32×2W_{in}\in\mathbb{R}^{32\times 2}, W32×32W\in\mathbb{R}^{32\times 32}, and Wout2×32W_{out}\in\mathbb{R}^{2\times 32}.

For each model, we choose the optimizer Adam with 1e-3 as the learning rate, 64 as the batch size, and 5 as the number of the training epochs.

We also utilize the synthetic datasets to address the regression problem of the time series. The optimizer for these datasets is chosen as the Adam with 0.010.01 as the learning rate and the mean absolute error (MAE) as the loss function. In this article, we choose the true time delays of the underlying systems for the NDDEs. We describe the structures of the models for the synthetic datasets as follows.

For the DDE 𝒙˙=𝑨tanh(𝒙(t)+𝒙(tτ))\dot{{\bm{x}}}={\bm{A}}\tanh({\bm{x}}(t)+{\bm{x}}(t-\tau)), we generate a trajectory by choosing its parameters as τ=0.5\tau=0.5, A=[[1,1],[1,1]]A=[[-1,1],[-1,-1]], 𝒙(t)=[0,1]{\bm{x}}(t)=[0,1] for t0t\leq 0, the final time T=2.5T=2.5, and the sampling time period equal to 0.10.1. We model it using the NODE and the NDDE, whose structures are illustrated, respectively, as:

  1. 1.

    Structure of the NODE: the vector field is modeled as

    f(x)=Wouttanh(Winx),f(x)=W_{out}\tanh(W_{in}x),

    where Win10×2W_{in}\in\mathbb{R}^{10\times 2} and Wout2×10W_{out}\in\mathbb{R}^{2\times 10};

  2. 2.

    Structure of the NDDE: the vector field is modeled as

    f(x(t),x(tτ))=Wouttanh(Win(x(t)+x(tτ))),f(x(t),x(t-\tau))=W_{out}\tanh(W_{in}(x(t)+x(t-\tau))),

    where Win10×2W_{in}\in\mathbb{R}^{10\times 2} and Wout2×10W_{out}\in\mathbb{R}^{2\times 10}.

We use the whole trajectory to train the models with the total iterations equal to 50005000.

For the population dynamics x˙=rx(t)(1x(tτ1))\dot{x}=rx(t)(1-x(t-\tau_{1})) with x(t)=x0x(t)=x_{0} for t0t\leq 0 and the Mackey-Glass systems x˙=βx(tτ)1+xn(tτ2)γx(t)\dot{x}=\beta\frac{x(t-\tau)}{1+x^{n}(t-\tau_{2})}-\gamma x(t) with x(t)=x0x(t)=x_{0} for t0t\leq 0, we choose the parameters as τ1=1\tau_{1}=1, τ2=1\tau_{2}=1, r=1.8r=1.8, β=4\beta=4, n=9.65n=9.65, and γ=2\gamma=2. We then generate 100100 different trajectories within the time interval [0,8][0,8] with 0.050.05 as the sampling time period for both the population dynamics and the Mackey-Glass systems. We split the trajectories into two parts. The first part within the time interval [0,3][0,3] is used as the training data. The other part is used for testing. We model both systems by applying the NODE, the NDDE, and the ANODE, whose structures are introduced, respectively, as:

  1. 1.

    Structure of the NODE: the vector field is modeled as

    f(x)=Wouttanh(Wtanh(Winx)),f(x)=W_{out}\tanh(W\tanh(W_{in}x)),

    where Win10×1W_{in}\in\mathbb{R}^{10\times 1}, W10×10W\in\mathbb{R}^{10\times 10}, and Wout1×10W_{out}\in\mathbb{R}^{1\times 10};

  2. 2.

    Structure of the NDDE: the vector field is modeled as

    f(x(t),x(tτ))=Wouttanh(Wtanh(Winconcat(x(t),x(tτ)))),f(x(t),x(t-\tau))=W_{out}\tanh(W\tanh(W_{in}\mbox{concat}(x(t),x(t-\tau)))),

    where Win10×2W_{in}\in\mathbb{R}^{10\times 2}, W10×10W\in\mathbb{R}^{10\times 10}, and Wout1×10W_{out}\in\mathbb{R}^{1\times 10}.

  3. 3.

    Structure of the ANODE: the vector field is modeled as

    f(𝒙aug(t))=Wouttanh(Wtanh(Win𝒙aug)),f({\bm{x}}_{aug}(t))=W_{out}\tanh(W\tanh(W_{in}{\bm{x}}_{aug})),

    where Win10×2W_{in}\in\mathbb{R}^{10\times 2}, W10×10W\in\mathbb{R}^{10\times 10}, Wout2×10W_{out}\in\mathbb{R}^{2\times 10}, and the augmented dimension is equal to 11. Notably, we need to align the augmented trajectories with the target trajectories to be regressed. To do it, we choose the data in the first component and exclude the data in the augmented component, i.e., simply projecting the augmented data into the space of the target data.

We train each model for the total 30003000 iterations.

B.2 Image datasets

The image experiments shown in this article are mainly depend on the code provided in (Dupont et al., 2019). Also, the structures of each model almost follow from the structures proposed in (Dupont et al., 2019). More precisely, we apply the convolutional block with the following strutures and dimensions

  • 1×11\times 1 conv, kk filters, 0 paddings,

  • ReLU activation function,

  • 3×33\times 3 conv, kk filters, 11 paddings,

  • ReLU activation function,

  • 1×11\times 1 conv, cc filters, 0 paddings,

where kk is different for each model and cc is the number of the channels of the input images. In Tab. 2, we specify the information for each model. As can be seen, we fix approximately the same number of the parameters for each model. We select the hyperparamters for the optimizer Adam through 1e-3 as the learning rate, 256256 as the batch size, and 3030 as the number of the training epochs.

CIFAR10 MNIST SVHN
NODE 92/10764592/107645 92/8439592/84395 92/10764592/107645
NDDE 92/10792192/107921 92/8448792/84487 92/10792192/107921
NODE+NDDE 64/10568064/105680 64/8215664/82156 64/10568064/105680
A1+NODE 86/10839886/108398 87/8433587/84335 86/10839886/108398
A1+NDDE 85/10718985/107189 86/8294486/82944 85/10718985/107189
A1+NODE+NDDE 60/10721860/107218 61/8352661/83526 60/10721860/107218
A2+NODE 79/10833279/108332 81/8323081/83230 79/10833279/108332
A2+NDDE 78/10729778/107297 81/8347381/83473 78/10729778/107297
A2+NODE+NDDE 55/10726555/107265 57/8310157/83101 55/10726555/107265
A4+NODE 63/10842663/108426 70/8415570/84155 63/10842663/108426
A4+NDDE 62/10771962/107719 69/8323769/83237 62/10771962/107719
A4+NODE+NDDE 43/10666343/106663 49/8385949/83859 43/10666343/106663
Table 2: The number of the filters and the whole parameters in each model used for CIFAR10, MNIST, and SVHN. In the first column, App with p=1,2,4p=1,2,4 indicates the augmentation of the image space c×h×w(c+p)×h×w\mathbb{R}^{c\times h\times w}\rightarrow\mathbb{R}^{(c+p)\times h\times w}.

Appendix C Additional results for the experiments

Refer to caption
Figure 9: The phase portraits of the population dynamics in the training and the test stages. We only show the 10 phase portraits from the total 100 phase portraits for the training and the testing time-series. Here, the solid lines correspond to the true dynamics, while the dash lines correspond to the trajectories generated by the trained models in the training duration and in the test duration, respectively.
Refer to caption
Figure 10: The phase portraits of the Makey-Glass systems exhibiting chaotic dynamics in the training and the test stages. We only present the 10 phase portraits from the total 100 phase portraits for the training and the testing time-series. Here, the solid lines correspond to the true dynamics, while the dash lines correspond to the trajectories generated by the trained models in the training duration and in the test duration, respectively.
Refer to caption
Figure 11: Evolution of the forward number of the function evaluations (NFEs) during the training process for each model on the image datesets, CIFAR10, MNIST, and SVHN.
Refer to caption
Figure 12: Evolution of the backward number of the function evaluations (NFEs) during the training process for each model on the image datesets, CIFAR10, MNIST, and SVHN.