Patent Publication Number: US-2022215254-A1

Title: Device and method for training the neural drift network and the neural diffusion network of a neural stochastic differential equation

Description:
CROSS REFERENCE 
     The present application claims the benefit under 35 U.S.C. § 119 of German Patent Application No. DE 102021200042.8 filed on Jan. 5, 2021, which is expressly incorporated herein by reference in its entirety. 
     FIELD 
     Various exemplary embodiments relate generally to a device and a method for training the neural drift network and the neural diffusion network of a neural stochastic differential equation. 
     BACKGROUND INFORMATION 
     A neural network which has sub-networks that model the drift term and the diffusion term according to a stochastic differential equation is referred to as a neural stochastic differential equation. Such a neural network makes it possible to predict values (e.g., temperature, material properties, speed, etc.) over several time steps, which may be used for a specific control (e.g., of a production process or a vehicle). 
     SUMMARY 
     In order to make accurate predictions, robust training of the neural network, that is, of the two sub-networks (drift network and diffusion network) is necessary. Efficient and stable approaches are desirable for this purpose. 
     According to various specific embodiments of the present invention, a method is provided for training the neural drift network and the neural diffusion network of a neural stochastic differential equation. The method includes the drawing of a training trajectory from training sensor data, the training trajectory having a training data point for each of a sequence of prediction instants, and—starting from the training data point which the training trajectory includes for a starting instant—determining the data-point mean and the data-point covariance at the prediction instant for each prediction instant of the sequence of prediction instants. This is accomplished by determining from the data-point mean and the data-point covariance of one prediction instant, the data-point mean and the data-point covariance of the next prediction instant by ascertaining the expected values of the derivatives of each layer of the neural drift network according to its input data, ascertaining the expected value of the derivative of the neural drift network according to its input data from the ascertained expected values of the derivatives of the layers of the neural drift network, and ascertaining the data-point mean and the data-point covariance of the next prediction instant from the ascertained expected value of the derivative of the neural drift network according to its input data. The method also includes determining a dependency of the probability that the data-point distributions of the prediction instants—which are given by the ascertained data-point means and the ascertained data-point covariances—will supply the training data points at the prediction instants, on the weights of the neural drift network and of the neural diffusion network, and adapting the neural drift network and the neural diffusion network to increase the probability. 
     The training method described above permits deterministic training of the neural drift network and the neural diffusion network of a neural stochastic differential equation, (that is, a deterministic inference of the weights of this neural network). In this context, the power of neural stochastic differential equations, their non-linearity, is retained, but a stable training is achieved and as a result, in particular, an efficient and robust provision of accurate predictions even for long sequences of prediction instants, (e.g., for long prediction intervals). 
     Various exemplary embodiments of the present invention are described in the following. 
     Exemplary embodiment 1 is a training method as described above. 
     Exemplary embodiment 2 is the method according to exemplary embodiment 1, whereby the ascertainment from the data-point mean and the data-point covariance of one prediction instant, the data-point mean and the data-point covariance of the next prediction instant features: 
     Determining, for the prediction instant, the mean and the covariance of the output of each layer of the neural drift network starting from the data-point mean and the data-point covariance of the prediction instant; and 
     Determining the data-point mean and the data-point covariance of the next prediction instant from the data-point means and data-point covariances of the layers of the neural drift network ascertained for the prediction instant. 
     Illustratively, according to various specific embodiments, a layer-wise moment matching is carried out. Consequently, the moments may be propagated deterministically through the neural networks, and no sampling is necessary to determine the distributions of the outputs of the neural networks. 
     Exemplary embodiment 3 is the method according to exemplary embodiment 1 or 2, whereby the ascertainment from the data-point mean and the data-point covariance of one prediction instant, the data-point mean and the data-point covariance of the next prediction instant features: 
     Determining, for the prediction instant, the mean and the covariance of the output of each layer of the neural diffusion network starting from the data-point mean and the data-point covariance of the prediction instant; and 
     Determining the data-point mean and the data-point covariance of the next prediction instant from the data-point means and data-point covariances of the layers of the neural diffusion network ascertained for the prediction instant. 
     In this way, the contribution of the diffusion network to the data-point covariance of the next prediction instant may be ascertained deterministically and efficiently, as well. 
     Exemplary embodiment 4 is the method according to one of exemplary embodiments 1 through 3, whereby the expected value of the derivative of the neural drift network according to its input data is determined by multiplying the derivatives of the ascertained expected values of the derivatives of the layers of the neural drift network. 
     This permits exact and simple calculation of the gradients of the complete networks from those of the individual layers. 
     Exemplary embodiment 5 is the method according to one of exemplary embodiments 1 through 4, whereby determination of the data-point covariance of the next prediction instant from the data-point mean and the data-point covariance of one prediction instant features: 
     Determining the covariance between input and output of the neural drift network for the prediction instant by multiplying the data-point covariance of the prediction instant by the expected value of the derivative of the neural drift network according to its input data; and 
     Determining the data-point covariance of the next prediction instant from the covariance between input and output of the neural drift network for the prediction instant. 
     This procedure permits efficient determination of the covariance between input and output of the neural drift network. This is highly important for the training, since this covariance is not necessarily semi-definite, and an inaccurate determination may lead to numerical instability. 
     Exemplary embodiment 6 is the method according to one of exemplary embodiments 1 through 5, featuring formation of the neural drift network and the neural diffusion network (only) from ReLU activations, dropout layers and layers for affine transformations. 
     A construction of the networks from layers of this type permits precise determination of the gradients of the derivatives of the output of the layers according to their inputs without sampling. 
     Exemplary embodiment 7 is the method according to one of exemplary embodiments 1 through 6, featuring formation of the neural drift network and the neural diffusion network so that the ReLU activations, dropout layers and layers for affine transformations alternate in the neural drift network. 
     This ensures that the assumption of a normal distribution for the data points is justified and the distribution of a data point at a prediction instant may thus be given with high accuracy by indicating the data-point mean and data-point covariance with respect to the prediction instant. 
     Exemplary embodiment 8 is the method for controlling a robot device, featuring: 
     Training of a neural stochastic differential equation in conformity with the method according to one of exemplary embodiments 1 through 7; 
     Measuring of sensor data which characterize a state of the robot device and/or one or more objects in the area surrounding the robot device; 
     Supplying the sensor data to the stochastic differential equation to produce a regression result; and 
     Controlling the robot device utilizing the regression result. 
     Exemplary embodiment 9 is a training device which is equipped to carry out the method according to one of exemplary embodiments 1 through 7. 
     Exemplary embodiment 10 is a control device for a robot device, which is equipped to carry out the method according to exemplary embodiment 8. 
     Exemplary embodiment 11 is a computer program having program instructions which, when executed by one or more processors, prompt the one or more processors to carry out a method according to one of exemplary embodiments 1 through 8. 
     Exemplary embodiment 12 is a computer-readable storage medium on which program instructions are stored which, when executed by one or more processors, prompt the one or more processors to carry out a method according to one of exemplary embodiments 1 through 8. 
     Exemplary embodiments of the present invention are represented in the figures and explained in greater detail in the following. In the figures, identical reference numerals everywhere in the various views relate generally to the same parts. The figures are not necessarily true to scale, the focus instead being generally the presentation of the principles of the present invention. 
    
    
     
       BRIEF DESCRIPTION OF THE DRAWINGS 
         FIG. 1  shows an example for a regression in the case of autonomous driving, in accordance with an example embodiment of the present invention. 
         FIG. 2  illustrates a method for determining the moments of the distribution of data points for one instant from the moments of the distribution of the data points for the previous instant, in accordance with an example embodiment of the present invention. 
         FIG. 3  shows a flowchart which illustrates a method for training the neural drift network and the neural diffusion network of a neural stochastic differential equation, in accordance with an example embodiment of the present invention. 
     
    
    
     DETAILED DESCRIPTION OF EXAMPLE EMBODIMENTS 
     The various specific embodiments, especially the exemplary embodiments described in the following, may be implemented with the aid of one or more circuits. In one specific embodiment, a “circuit” may be understood to be any type of logic-implementing entity, which may be hardware, software, firmware or a combination thereof. Therefore, in one specific embodiment, a “circuit” may be a hard-wired logic circuit or a programmable logic circuit such as a programmable processor, e.g., a microprocessor. A “circuit” may also be software which is implemented or executed by a processor, e.g., any type of computer program. Any other type of implementation of the respective functions, which are described in greater detail hereinafter, may also be understood to be a “circuit” in accordance with an alternative specific embodiment. 
       FIG. 1  shows an example for a regression in the case of autonomous driving. 
     In the example of  FIG. 1 , a vehicle  101 , e.g., an automobile, a delivery truck or a motorcycle, has a vehicle control device  102 . 
     Vehicle control device  102  includes data-processing components, for example, a processor (e.g., a CPU (central processing unit))  103  and a memory  104  for storing the control software according to which vehicle control device  102  functions, and the data on which processor  103  operates. 
     In this example, the stored control software has instructions which, when executed by processor  103 , prompt the processor to implement a regression algorithm  105 . 
     The data stored in memory  104  may include input sensor data from one or more sensors  107 . For example, the one or more sensors  107  may include a sensor which measures the speed of vehicle  101 , as well as sensor data which represent the curve of the road (that may be derived, for instance, from image sensor data, which are processed by object detection to determine the direction of travel), the condition of the road, etc. Thus, for example, the sensor data may be multidimensional (curve, road condition, . . . ). The regression result may be one-dimensional, for instance. 
     Vehicle control  102  processes the sensor data and determines a regression result, e.g., a maximum speed, and is able to control the vehicle on the basis of the regression result. For instance, a brake  108  may be activated if the regression result indicates a maximum speed which is higher than a measured instantaneous speed of vehicle  101 . 
     Regression algorithm  105  may have a machine learning model  106 . Machine learning model  106  may be trained utilizing training data in order to make predictions (e.g., a maximum speed). 
     One widely used model of machine learning is a deep neural network. A deep neural network is trained to implement a function which converts input data (in other words: an input pattern) in non-liner fashion into output data (an output pattern). 
     According to various specific embodiments, the machine learning model has a neural stochastic differential equation. 
     A non-linear time-invariant stochastic differential equation (SDE) has the form 
         dx=f   θ ( x ) dt+L   ϕ ( x ) dw    
     In this context, f θ (x)∈   D  is the drift function which models the deterministic component of the respective vector field, and L ϕ (x)∈   D×S  is the diffusion function which models the stochastic component. dt is the time increment and w∈   S  denotes a Wiener process. 
     SDEs are typically not solvable analytically. Numerical approaches to a solution typically utilize a discretization of the time domain and an approximation of the transition in a time step. One possibility for that purpose is the Euler-Maruyama (EM) discretization 
         {tilde over (x)}   k+1   (θ,ϕ)   =x   k   +f   θ ( x   k )Δ t+L   ϕ ( x   k )Δ w   k  
 
       where 
       Δ w   k ˜ (0,Δ t )
 
     The solution process begins with an initial state x 0 , and the final state w K  after the last time step is the regression result, for example. 
     The term “neural stochastic differential equation” relates to the case where f θ (x) and (possibly) L ϕ (x) are given by neural networks (NNs) with weights θ and ϕ, respectively. Even for moderate NN architectures, a neural stochastic differential equation may have many thousand free parameters (i.e., weights) which makes finding the weights from training data, that is, the inference, a challenging task. 
     In the following, it is assumed that the parameters of a neural stochastic differential equation are found with the aid of Maximum Likelihood Estimation (MLE), that is, by 
     
       
         
           
             
               max 
               
                 θ 
                 , 
                 ϕ 
               
             
             ⁢ 
             
                 
             
             ⁢ 
             
               
                 𝔼 
                 ⁡ 
                 
                   [ 
                   
                     log 
                     ⁢ 
                     
                         
                     
                     ⁢ 
                     
                       
                         p 
                         
                           θ 
                           , 
                           ϕ 
                         
                       
                       ⁡ 
                       
                         ( 
                         𝒟 
                         ) 
                       
                     
                   
                   ] 
                 
               
               . 
             
           
         
       
     
     This permits the joint learning of θ and ϕ from data. Alternatively, it is also possible to carry out a variation inference, e.g., according to 
     
       
         
           
             
               maximize 
               θ 
             
             ⁢ 
             
                 
             
             ⁢ 
             
               𝔼 
               ⁡ 
               
                 [ 
                 
                   
                     log 
                     ⁢ 
                     
                         
                     
                     ⁢ 
                     
                       
                         p 
                         
                           θ 
                           , 
                           ϕ 
                         
                       
                       ⁡ 
                       
                         ( 
                         𝒟 
                         ) 
                       
                     
                   
                   - 
                   
                     
                       1 
                       2 
                     
                     ⁢ 
                     
                       ∫ 
                       
                         
                           
                              
                             
                               u 
                               ⁡ 
                               
                                 ( 
                                 x 
                                 ) 
                               
                             
                              
                           
                           2 
                         
                         ⁢ 
                         dt 
                       
                     
                   
                 
                 ] 
               
             
           
         
       
     
     where L ϕ (χ)u(χ)=f θ (χ)−f ψ (χ) and f ψ (χ) is the A-priori drift. 
     The estimation of the anticipated likelihood is typically not possible analytically. In addition, sampling-based approximations typically lead to an unstable training and result in neural networks with inaccurate predictions. 
     According to various specific embodiments, these undesirable effects of the sampling are avoided and a deterministic procedure is given for the inference of the weights of the neural networks, which model the drift function and the diffusion function. 
     According to various specific embodiments, this procedure includes that a numerically tractable process density is used for the modeling, the Wiener process w is marginalized and the uncertainty of the states x k  is marginalized. The uncertainty in the states comes from (i) the original distribution p(x 0 ,t 0 ) as well as from the diffusion term L ϕ (x k ). 
     It should be noted that for simplicity, A-priori distributions for the weights of the neural networks are omitted. However, the approaches described may also be used for Bayesian neural networks. Such an A-priori distribution does not necessarily have to be given via the weights, but may also be in the form of a differential equation. 
     According to various specific embodiments, p(x,t)≈ (x|m(t),P(t)) is used as the process distribution, which leads to a Gaussian process approximation with mean and covariance that change over time. 
     For example, if a time discretization with K steps of an interval [0, T] is used, that is, {t k ∈[0,T]|k=1, . . . ,K}, then the process variables x 1 , . . . , x K  (also referred to as states) have the distributions p(x 1 ,t 1 ),p(x 2 ,t 2 ), . . . ,p(x K ,t K ). The elements of this sequence of distributions may be approximated by recursive moment matching in the forward direction (that is, in the direction of ascending indices). 
     It is assumed that variable x k+1  at instant t k+1  has a Gaussian distribution with density 
         p   θ,ϕ (χ k+1   ,t   k+1   ;p   θ,ϕ (χ k   ,t   k ))≈ (χ k+1   |m   k+1   ,P   k+1 )
 
     where the moments m k+1 ,P k+1  are determined from the already matched moments of the distribution (that is, the density) at the previous instant p θ,ϕ (x k , t k ). 
     It is assumed that the first two moments of the density at the next instant are equal to the first two moments one EM (Euler-Maruyama} step forward following integration via the state at the current instant: 
     
       
         
           
             
                 
             
             ⁢ 
             
               
                 
                   m 
                   
                     k 
                     + 
                     1 
                   
                 
                 ⁢ 
                 
                   = 
                   Δ 
                 
                 ⁢ 
                 
                   ∫ 
                   
                     
                       ∫ 
                       
                         ℝ 
                         
                           D 
                           × 
                           S 
                         
                       
                     
                     ⁢ 
                     
                       
                         
                           x 
                           ~ 
                         
                         
                           k 
                           + 
                           1 
                         
                         
                           ( 
                           
                             θ 
                             , 
                             ϕ 
                           
                           ) 
                         
                       
                       ⁢ 
                       
                         
                           
                             p 
                             
                               θ 
                               , 
                               ϕ 
                             
                           
                           ⁡ 
                           
                             ( 
                             
                               
                                 x 
                                 k 
                               
                               , 
                               
                                 t 
                                 k 
                               
                             
                             ) 
                           
                         
                         
                           ︸ 
                           
                             ≈ 
                             
                               𝒩 
                               ⁡ 
                               
                                 ( 
                                 
                                   
                                     
                                       x 
                                       k 
                                     
                                     ❘ 
                                     
                                       m 
                                       k 
                                     
                                   
                                   , 
                                   
                                     P 
                                     k 
                                   
                                 
                                 ) 
                               
                             
                           
                         
                       
                       ⁢ 
                       
                         p 
                         ⁡ 
                         
                           ( 
                           
                             w 
                             k 
                           
                           ) 
                         
                       
                       ⁢ 
                       
                         dw 
                         k 
                       
                       ⁢ 
                       
                         dx 
                         k 
                       
                     
                   
                 
               
               , 
               
                 
 
               
               ⁢ 
               
                 
                   P 
                   
                     k 
                     + 
                     1 
                   
                 
                 ⁢ 
                 
                   = 
                   Δ 
                 
                 ⁢ 
                 
                   ∫ 
                   
                     
                       ∫ 
                       
                         ℝ 
                         
                           D 
                           × 
                           S 
                         
                       
                     
                     ⁢ 
                     
                       
                         ( 
                         
                           
                             
                               x 
                               ~ 
                             
                             
                               k 
                               + 
                               1 
                             
                             
                               ( 
                               
                                 θ 
                                 , 
                                 ϕ 
                               
                               ) 
                             
                           
                           - 
                           
                             m 
                             
                               k 
                               + 
                               1 
                             
                           
                         
                         ) 
                       
                       ⁢ 
                       
                         
                           ( 
                           
                             
                               
                                 x 
                                 ~ 
                               
                               
                                 k 
                                 + 
                                 1 
                               
                               
                                 ( 
                                 
                                   θ 
                                   , 
                                   ϕ 
                                 
                                 ) 
                               
                             
                             - 
                             
                               m 
                               
                                 k 
                                 + 
                                 1 
                               
                             
                           
                           ) 
                         
                         T 
                       
                       ⁢ 
                       
                         
                           
                             p 
                             
                               θ 
                               , 
                               ϕ 
                             
                           
                           ⁡ 
                           
                             ( 
                             
                               
                                 x 
                                 k 
                               
                               , 
                               
                                 t 
                                 k 
                               
                             
                             ) 
                           
                         
                         
                           ︸ 
                           
                             ≈ 
                             
                               𝒩 
                               ⁡ 
                               
                                 ( 
                                 
                                   
                                     
                                       x 
                                       k 
                                     
                                     ❘ 
                                     
                                       m 
                                       k 
                                     
                                   
                                   , 
                                   
                                     P 
                                     k 
                                   
                                 
                                 ) 
                               
                             
                           
                         
                       
                       ⁢ 
                       
                         p 
                         ⁡ 
                         
                           ( 
                           
                             w 
                             k 
                           
                           ) 
                         
                       
                       ⁢ 
                       
                         dw 
                         k 
                       
                       ⁢ 
                       
                         dx 
                         k 
                       
                     
                   
                 
               
               , 
             
           
         
       
     
     In this case, the dependency on the previous instant is produced by  (x k |m k ,P k ). 
     It now holds that if {tilde over (x)} k   (θ,ϕ)  follows the EM discretization, the updating rules given above for the first two moments satisfy the following analytical form with marginalized Wiener process w k : 
     
       
         
           
             
                 
             
             ⁢ 
             
               
                 
                   m 
                   
                     k 
                     + 
                     1 
                   
                 
                 = 
                 
                   
                     ∫ 
                     
                       ℝ 
                       D 
                     
                   
                   ⁢ 
                   
                     
                       
                         x 
                         ^ 
                       
                       
                         k 
                         + 
                         1 
                       
                       
                         ( 
                         
                           θ 
                           , 
                           ϕ 
                         
                         ) 
                       
                     
                     ⁢ 
                     
                       𝒩 
                       ⁡ 
                       
                         ( 
                         
                           
                             
                               x 
                               k 
                             
                             ❘ 
                             
                               m 
                               k 
                             
                           
                           , 
                           
                             P 
                             k 
                           
                         
                         ) 
                       
                     
                     ⁢ 
                     
                       dx 
                       k 
                     
                   
                 
               
               , 
               
                 
 
               
               ⁢ 
               
                 
                   P 
                   
                     k 
                     + 
                     1 
                   
                 
                 = 
                 
                   
                     ∫ 
                     
                       ℝ 
                       D 
                     
                   
                   ⁢ 
                   
                     
                       [ 
                       
                         
                           
                             ( 
                             
                               
                                 
                                   x 
                                   ^ 
                                 
                                 
                                   k 
                                   + 
                                   1 
                                 
                                 
                                   ( 
                                   
                                     θ 
                                     , 
                                     ϕ 
                                   
                                   ) 
                                 
                               
                               - 
                               
                                 m 
                                 
                                   k 
                                   + 
                                   1 
                                 
                               
                             
                             ) 
                           
                           ⁢ 
                           
                             
                               ( 
                               
                                 
                                   
                                     x 
                                     ^ 
                                   
                                   
                                     k 
                                     + 
                                     1 
                                   
                                   
                                     ( 
                                     
                                       θ 
                                       , 
                                       ϕ 
                                     
                                     ) 
                                   
                                 
                                 - 
                                 
                                   m 
                                   
                                     k 
                                     + 
                                     1 
                                   
                                 
                               
                               ) 
                             
                             T 
                           
                         
                         + 
                         
                           
                             L 
                             ϕ 
                           
                           ⁢ 
                           
                             
                               L 
                               ϕ 
                               T 
                             
                             ⁡ 
                             
                               ( 
                               
                                 x 
                                 k 
                               
                               ) 
                             
                           
                           ⁢ 
                           Δ 
                           ⁢ 
                           
                               
                           
                           ⁢ 
                           t 
                         
                       
                       ⌉ 
                     
                     ⁢ 
                     
                       𝒩 
                       ⁡ 
                       
                         ( 
                         
                           
                             
                               x 
                               k 
                             
                             ❘ 
                             
                               m 
                               k 
                             
                           
                           , 
                           
                             P 
                             k 
                           
                         
                         ) 
                       
                     
                     ⁢ 
                     
                       dx 
                       k 
                     
                   
                 
               
               , 
             
           
         
       
     
     where 
         {circumflex over (x)}   k+1   (θ,ϕ)     x   k   +f   θ ( x   k )Δ t  
 
     and Δt is a time step that is not dependent on Δw k . 
     In order to obtain a deterministic inference process, in these two equations, it is necessary to integrate via x k . Since in the normal case, the integrals are not solvable analytically, numerical approximation is used. 
     To that end, according to various specific embodiments, the moment matching is expanded to the effect that the two moments m k ,P k  (which clearly reflect the uncertainty in the current state) are propagated through the two neural networks (which model the drift function and the diffusion function). Hereinafter, this is also referred to as Layer-wise Moment Matching (LMM). 
       FIG. 2  illustrates a method for determining the moments m k+1 ,P k+1  for one instant from the moments m k ,P k  for the previous instant. 
     Neural SDE  200  has a first neural network  201  which models the drift term, and a second neural network  202  which models the diffusion term. 
     Utilizing the bilinearity of the covariance operation  Coli (⋅,⋅), the equations above may be rewritten so that 
     
       
         
           
             
                 
             
             ⁢ 
             
               
                 
                   m 
                   
                     k 
                     + 
                     1 
                   
                 
                 = 
                 
                   
                     m 
                     k 
                   
                   + 
                   
                     
                       𝔼 
                       ⁡ 
                       
                         [ 
                         
                           
                             f 
                             θ 
                           
                           ⁡ 
                           
                             ( 
                             
                               x 
                               k 
                             
                             ) 
                           
                         
                         ] 
                       
                     
                     ⁢ 
                     Δ 
                     ⁢ 
                     
                         
                     
                     ⁢ 
                     t 
                   
                 
               
               , 
               
                 
 
               
               ⁢ 
               
                 
                   P 
                   
                     k 
                     + 
                     1 
                   
                 
                 = 
                 
                   
                     P 
                     k 
                   
                   + 
                   
                     
                       Cov 
                       ⁡ 
                       
                         ( 
                         
                           
                             
                               f 
                               θ 
                             
                             ⁡ 
                             
                               ( 
                               
                                 x 
                                 k 
                               
                               ) 
                             
                           
                           , 
                           
                             
                               f 
                               θ 
                             
                             ⁡ 
                             
                               ( 
                               
                                 x 
                                 k 
                               
                               ) 
                             
                           
                         
                         ) 
                       
                     
                     ⁢ 
                     Δ 
                     ⁢ 
                     
                         
                     
                     ⁢ 
                     
                       t 
                       2 
                     
                   
                   + 
                   
                     
                       ( 
                       
                         
                           Cov 
                           ⁡ 
                           
                             ( 
                             
                               
                                 
                                   f 
                                   θ 
                                 
                                 ⁡ 
                                 
                                   ( 
                                   
                                     x 
                                     k 
                                   
                                   ) 
                                 
                               
                               , 
                               
                                 x 
                                 k 
                               
                             
                             ) 
                           
                         
                         + 
                         
                           Cov 
                           ⁡ 
                           
                             ( 
                             
                               
                                 x 
                                 k 
                               
                               , 
                               
                                 
                                   f 
                                   θ 
                                 
                                 ⁡ 
                                 
                                   ( 
                                   
                                     x 
                                     k 
                                   
                                   ) 
                                 
                               
                             
                             ) 
                           
                         
                       
                       ) 
                     
                     ⁢ 
                     Δ 
                     ⁢ 
                     
                         
                     
                     ⁢ 
                     t 
                   
                   + 
                   
                     
                       𝔼 
                       ⁡ 
                       
                         [ 
                         
                           
                             L 
                             ϕ 
                           
                           ⁢ 
                           
                             
                               L 
                               ϕ 
                               T 
                             
                             ⁡ 
                             
                               ( 
                               
                                 x 
                                 k 
                               
                               ) 
                             
                           
                         
                         ] 
                       
                     
                     ⁢ 
                     Δ 
                     ⁢ 
                     
                         
                     
                     ⁢ 
                     t 
                   
                 
               
               , 
             
           
         
       
     
     where Cov(x k ,x k ) is denoted as P k . The central moment of the diffusion term  [L ϕ L ϕ   T (x k )] may be estimated with the aid of LMM, if it is diagonal. However (except in trivial cases), the cross covariance Cov(f θ (x k ),x k ) cannot be estimated utilizing customary LMM techniques. It is not guaranteed that it is positive-semidefinite, and therefore may lead to an inaccurate estimation that P k+1  becomes singular, which adversely affects the numerical stability. 
     In the following, the output of the 1st layer of a neural network  201 ,  202  is denoted by x l ∈   D     l   . This output (according to the LMM procedure) is modeled as a multivariate Gaussian distribution with mean m l  and covariance P l . The index l=0 is used for the input to the first layer of (respective) neural network  201 ,  202 . 
     In order to make LMM usable, the critical term Cov(f θ (x k ),x k ) is reformulated. This is accomplished by utilizing the lemma of Stein, with whose aid this term may be written as 
       Cov( f   θ ( x   k ), x   k )=Cov( x   k   ,x   x ) [∇ x   f   θ ( x )]
 
     The problem is thereby reduced to the ascertainment of an expected value concerning the gradient of neural network  201   [∇ x g(x)], where g=f θ . (The term “gradient” is used here, even if f θ  is typically vector-valued, and consequently ∇ x f θ  has the form of a matrix, that is, is a Jacobian matrix; therefore, generally the term “derivative” is simply used, as well.) 
     In a neural network, the function g(x) is an interlinking of L functions (one per layer of the neural network), that is, 
         g ( x )= g   L   ºg   L−1   º . . . g   2   ºg   1 ( x ) 
     For suitable layers, it holds that 
     
       
         
           
             
               
                 
                   
                     𝔼 
                     ⁡ 
                     
                       [ 
                       
                         
                           ∇ 
                           x 
                         
                         ⁢ 
                         
                           g 
                           ⁡ 
                           
                             ( 
                             x 
                             ) 
                           
                         
                       
                       ] 
                     
                   
                   ⁢ 
                     
                   = 
                 
               
               
                 
                     
                   ⁢ 
                   
                     𝔼 
                     [ 
                     
                       
                         
                           ∂ 
                           
                             g 
                             L 
                           
                         
                         
                           ∂ 
                           
                             x 
                             
                               L 
                               - 
                               1 
                             
                           
                         
                       
                       ⁢ 
                       
                         
                           ∂ 
                           
                             g 
                             
                               L 
                               - 
                               1 
                             
                           
                         
                         
                           ∂ 
                           
                             x 
                             
                               L 
                               - 
                               2 
                             
                           
                         
                       
                       ⁢ 
                       … 
                       ⁢ 
                       
                         
                           ∂ 
                           
                             g 
                             2 
                           
                         
                         
                           ∂ 
                           
                             x 
                             1 
                           
                         
                       
                       ⁢ 
                       
                         
                           ∂ 
                           
                             g 
                             1 
                           
                         
                         
                           ∂ 
                           
                             x 
                             0 
                           
                         
                       
                     
                     ] 
                   
                 
               
             
             
               
                 
                     
                   = 
                 
               
               
                 
                     
                   ⁢ 
                   
                     
                       𝔼 
                       
                         x 
                         
                           L 
                           - 
                           1 
                         
                       
                     
                     [ 
                     
                       
                         
                           ∂ 
                           
                             g 
                             L 
                           
                         
                         
                           ∂ 
                           
                             x 
                             
                               L 
                               - 
                               1 
                             
                           
                         
                       
                       ⁢ 
                       
                         
                           𝔼 
                           
                             x 
                             
                               L 
                               - 
                               2 
                             
                           
                         
                         [ 
                         
                           
                             
                               ∂ 
                               
                                 g 
                                 
                                   L 
                                   - 
                                   1 
                                 
                               
                             
                             
                               ∂ 
                               
                                 x 
                                 
                                   L 
                                   - 
                                   2 
                                 
                               
                             
                           
                           ⁢ 
                           … 
                         
                       
                     
                   
                 
               
             
             
               
                   
               
               
                 
                   
                     
                         
                       ⁢ 
                       
                         
                           
                             𝔼 
                             
                               x 
                               1 
                             
                           
                           [ 
                           
                             
                               
                                 ∂ 
                                 
                                   g 
                                   2 
                                 
                               
                               
                                 ∂ 
                                 
                                   x 
                                   1 
                                 
                               
                             
                             ⁢ 
                             
                               
                                 𝔼 
                                 
                                   x 
                                   0 
                                 
                               
                               [ 
                               
                                 
                                   ∂ 
                                   
                                     g 
                                     1 
                                   
                                 
                                 
                                   ∂ 
                                   
                                     x 
                                     0 
                                   
                                 
                               
                               ] 
                             
                           
                           ] 
                         
                         ⁢ 
                         … 
                       
                       ] 
                     
                     ] 
                   
                   . 
                 
               
             
           
         
       
     
     In order to determine this interleaving of expected values, the distribution of x l , denoted as p(x l ), is assumed as a Gaussian distribution. The intermediate results p(x l ) are used for determining m L  and P L . Subsequently, the anticipated gradient of each layer in relation to a normal distribution is determined by forward-mode differentiation. According to one specific embodiment, affine transformation, ReLU activation and dropout are used as suitable functions g l , for which m l  and P l  may be estimated in the case of a normally distributed input, and the anticipated gradient    χ     l−1   [∂g l /∂χ l −1] may be determined. Further types of functions or NN layers may also be utilized. 
     An affine transformation maps an input x l  onto an output x l+1 ∈   D     1+1    according to Ax l +b with weight matrix A∈   D     1+1     ×D     l    and bias b∈   D     l+1   . If the input is Gaussian-distributed, the output is also Gaussian-distributed with the moments, 
     
       
      
       m 
       l+1 
       =Am 
       l 
       +b,  
      
     
     
       
      
       p 
       l+1 
       =AP 
       l 
       A 
       T  
      
     
     and anticipated gradient    x     l   [∂g l+1 /∂χ l ]=A. 
     The output of a ReLU activation of an input x l  is x l+1 =max(0,x l ). Because of the non-linearity of the ReLU activation, the output in the case of a Gaussian-distributed input is generally not Gaussian-distributed, but its moments may be estimated as 
         m   l+1 =√{square root over (diag( P   l ))} SR ( m   l /√{square root over (diag( P   l ))}),
 
         P   l+1 =√{square root over (diag( P   l ))}√{square root over (diag( P   l ))} T   F ( m   l   ,P   l ),
 
       where 
         SR (μ l )=(ϕ(μ l )+μ l Φ(μ l ))
 
     with ϕ and Φ denoting the density and cumulative distribution function [of] a standard, normally distributed random variable, as well as 
         F ( m   l   ,P   1 )=( A ( m   l   ,P   l )+exp− Q ( m   l   ,P   l )),
 
     in which A and Q may again be estimated. 
     The entries of the secondary diagonals of the expected gradient are zero and the diagonal entries are the expectation of the Heaviside function: 
     
       
         
           
             
               diag 
               ( 
               
                 
                   𝔼 
                   
                     x 
                     l 
                   
                 
                 [ 
                 
                   
                     ∂ 
                     
                       g 
                       
                         l 
                         + 
                         1 
                       
                     
                   
                   
                     ∂ 
                     
                       x 
                       l 
                     
                   
                 
                 ] 
               
               ) 
             
             = 
             
               
                 Φ 
                 ⁡ 
                 
                   ( 
                   
                     
                       m 
                       l 
                     
                     ⁢ 
                     
                       / 
                     
                     ⁢ 
                     
                       
                         diag 
                         ⁡ 
                         
                           ( 
                           
                             P 
                             l 
                           
                           ) 
                         
                       
                     
                   
                   ) 
                 
               
               . 
             
           
         
       
     
     In the case of dropout, a multivariate variable z∈   D     l    is drawn (i.e., sampled) from a Bernoulli distribution z i ˜Bernoulli(ρ) independently for each activation channel and the non-linearity x l+1 =(Z⊙x l )/ρ is used, ‘⊙’ denoting the Hadamard multiplication and rescaling being carried out with ρ in order to obtain the expected value. The mean and the covariance of the output may be estimated by 
     
       
         
           
             
               
                 m 
                 
                   l 
                   + 
                   1 
                 
               
               = 
               
                 m 
                 l 
               
             
             , 
             
               
 
             
             ⁢ 
             
               
                 P 
                 
                   l 
                   + 
                   1 
                 
               
               = 
               
                 
                   P 
                   l 
                 
                 + 
                 
                   
                     diag 
                     ⁡ 
                     
                       ( 
                       
                         
                           q 
                           p 
                         
                         ⁢ 
                         
                           ( 
                           
                             
                               P 
                               l 
                             
                             + 
                             
                               
                                 ( 
                                 
                                   m 
                                   l 
                                 
                                 ) 
                               
                               ⁢ 
                               
                                 
                                   ( 
                                   
                                     m 
                                     l 
                                   
                                   ) 
                                 
                                 T 
                               
                             
                           
                           ) 
                         
                       
                       ) 
                     
                   
                   . 
                 
               
             
           
         
       
     
     The expected gradient is equal to the identity 
           x     l   [∂ g   l+1 /∂χ l ]= I  
 
     Dropout permits the components of an input x˜ρ(x) for any distribution ρ(x) to be approximately de-correlated, since diag(P l+1 )&gt;diag(P l ) on the basis of diag(P l +(m l )(m l ) T )&gt;0 (in each case viewed component-wise). However, the entries outside of the diagonals may be unequal to zero, so that only an approximate de-correlation is carried out. If an approximately de-correlated output of a dropout layer x l+1  is processed by an affine transformation, it is assumed that the following output x l+2  corresponds to a sum of independently distributed random variables and therefore (according to the central limit theorem), is accepted as Gaussian-distributed. 
     For each k and neural drift network  201 , the moments m k ,P k  are thus used as moments m k   0 ,P k   0  of input  203  of neural drift network  201 , and from them, the moments m k   1 ,P k   1 , m k   2 ,P k   2 , m k   3 ,P k   3  of outputs  204 ,  205 ,  206  of the layers are determined according to the rules above. They are utilized to determine the expected value and covariance  207  as well as to determine expected gradient  208 . 
     For diffusion network  202 , in addition,  [L ϕ ] and Cov(L ϕ ,L ϕ ) are determined, and from all of these results  209 , the moments m k+1 ,P k+1  for the next instant k+1 are determined. 
     In the following, an algorithm is indicated for training an NSDE in pseudo-code utilizing a training data record  . 
     
       
         
           
               
               
             
               
                   
               
             
            
               
                   
                 Input: f θ , L ϕ ,    
               
               
                   
                 Output: Optimized θ, ϕ 
               
               
                   
                 So long as no convergence yet exists 
               
               
                   
                  {({circumflex over (x)} 1   (n) , {circumflex over (t)} 1   (n) ), . . . , ({circumflex over (x)} K     n     (n) , {circumflex over (t)} K     n     (n) )} ~    (Drawing a training 
               
               
                   
                  trajectory from the training data record) 
               
               
                   
                  m 1  = {circumflex over (x)} 1   (n) , P 1  = Iϵ (Gaussian approximation of a Dirac 
               
               
                   
                 distribution) 
               
               
                   
                  m 1:K , P 1:K  = DNSDE_Stein(m 1 , P 1 , t 1:K   (n) ) 
               
               
                   
                  
       θ   ,     ϕ   =       argmax     θ   ,   ϕ       ⁢       ∑     k   =   2     K     ⁢     log   ⁢           ⁢     𝒩   ⁡     (           x   ^     k     (   n   )       |     m   k       ,     P   k       )       ⁢           ⁢     (   MLE   )                 
 
               
               
                   
                 Output θ, ϕ 
               
               
                   
               
            
           
         
       
     
     The result of the MLE for a training trajectory is used to adjust the previous estimation of θ, ϕ, until a convergence criterion is satisfied, e.g., θ, ϕ change only a little (or alternatively, a maximum number of iterations is reached). 
     The function DNSDE_Stein reads as follows in pseudo-code 
     
       
         
           
               
             
               
                   
               
             
            
               
                 DNSDE_Stein (m 1 , P 1 , t 1:K )  
               
               
                 for k ← 1:K −1 
               
               
                 m f , P f , J = DriftMoments&amp;Jac (m k , P k ) 
               
               
                 m L , P L  = DiffusionMoments (m k , P k ) 
               
               
                 m k + 1  = m k  + m f Δt) 
               
               
                 p xf  = P k J 
               
               
                 P L,centered  = PL + m L m L   T  ⊙ I 
               
               
                 P k + 1  = P k  + P f Δt 2   
               
               
                 P k + 1  = P k + 1  + (P xf  + P xf   T  + P L,centered )Δt 
               
               
                   
               
            
           
         
       
     
     The fourth line in the “for” loop is the use of the lemma of Stein. The following line determines  [L ϕ L ϕ   T (χ k , t k )] 
     The function Driftmoments&amp;Jac reads as follows in pseudo-code 
     
       
         
           
               
             
               
                   
               
             
            
               
                 Driftmoments&amp;Jac (m, P) 
               
               
                 J = I 
               
               
                 for layer in f θ   
               
               
                 J i  = layer.expected gradient (m, P) 
               
               
                 J = J i J (Chain rule in forward mode) 
               
               
                 m, P = layer.next_moments (m, P) 
               
               
                 Give back m, P, J 
               
               
                   
               
            
           
         
       
     
     The function DiffusionMoments reads as follows in pseudo-code 
     
       
         
           
               
             
               
                   
               
             
            
               
                 DiffusionMoments (m, P) 
               
               
                 for layer in L ϕ   
               
               
                 m, P = layer.next_moments (m, P) 
               
               
                  P = P ⊙ I (Set diagonal elements to zero) 
               
               
                 Give back m, P 
               
               
                   
               
            
           
         
       
     
     In the pseudocode above, the moments (from the starting instant k=1 up to the final instant k=K) and the covariances (from the starting instant k=1 up to the final instant k=K) are denoted by m 1:K  and P 1:K  respectively. The moments of the starting instant are m 1  and P 1 . In the algorithm above, P 1 ≈I∈ and m 1 ={circumflex over (x)} 1   (n)  are used in order to condition to the observed initial state {circumflex over (x)} 1   (n)  (for the nth training data record). In this case, ∈ is a small number, e.g., ∈=10 −4 . In the example above, the output matrix of the diffusion function L ϕ (x) is diagonal and its second moment is likewise diagonal. With the aid of LMM, the functions DriftMoments&amp;Jac and DiffusionMoments estimate the first two moments of the output of drift network  201  and of diffusion network  202  for an input with the moments such as the two functions obtain via their arguments. In addition, in this example, it is assumed that neural networks  201 ,  202  are constructed in such a way that ReLU activations, dropout layers and affine transformations alternate, so that the output of the affine transformation is approximately normally distributed. In the case of the evaluation of DriftMoments&amp;Jac, the expected gradient  [∇ x g(x)] is estimated in the forward mode. For dropout layers and affine transformations, the expected gradient is independent of the distribution of the input. Only in the case of a ReLU activation is the expected gradient dependent on the input distribution (which is approximately a normal distribution). 
     In the pseudo-code above, a class layer is used, of which it is assumed that it has the functions expected_gradient and next_moments which implement the equations, indicated above for the various layers, for the moments of the output of the layer and of the expected gradient. 
     In summary, according to various specific embodiments, a method is provided as represented in  FIG. 3 . 
       FIG. 3  shows a flowchart  300  which illustrates a method for training the neural drift network and the neural diffusion network of a neural stochastic differential equation. 
     In  301 , a training trajectory is drawn (sampled, e.g., selected randomly) from training sensor data, the training trajectory having a training data point for each of a sequence of prediction instants. 
     In  302 , starting from the training data point which the training trajectory contains for a starting instant, the data-point mean and the data-point covariance at the prediction instant are determined for each prediction instant of the sequence of prediction instants. 
     This is accomplished by determining from the data-point mean and the data-point covariance of one prediction instant, the data-point mean and the data-point covariance of the next prediction instant by
         Determining the expected values of the derivatives of each layer of the neural drift network according to their input data;   Determining the expected value of the derivative of the neural drift network according to its input data from the ascertained expected values of the derivatives of the layers of the neural drift network; and   Determining the data-point mean and the data-point covariance of the next prediction instant from the ascertained expected value of the derivative of the neural drift network according to its input data.       

     In  303 , a dependency of the probability that the data-point distributions of the prediction instants—which are given by the ascertained date-point means and the ascertained data-point covariances—will supply the training data points at the prediction instants, on the weights of the neural drift network and of the neural diffusion network is determined. 
     In  304 , the neural drift network and the neural diffusion network are adapted to increase the probability. 
     In other words, according to various specific embodiments, the moments of the distribution of the data points at the various time steps are determined by utilizing the expected values of the derivatives of the neural networks (drift network and diffusion network). These expected values of the derivatives are initially determined layer-wise and are then combined to form the expected values of the derivatives of the neural networks. 
     According to various specific embodiments, the moments of the distributions of the data points at the various time steps are then determined by layer-wise (e.g., recursive) moment matching. Simply put, according to various specific embodiments, the moments of the distributions of the data points (and consequently the uncertainty of the data points) are propagated through the layers and via time steps. 
     This is carried out for training data, and the parameters of the neural networks (weights) are optimized with the aid of Maximum Likelihood Estimation, for example. 
     The trained neural stochastic differential equation may be used to control a robot device. 
     A “robot device” may be understood to be any physical system (having a mechanical part whose movement is controlled), such as a computer-controlled machine, a vehicle, a household appliance, a power tool, a manufacturing machine, a personal assistant or an access control system. 
     The control may be carried out based on sensor data. This sensor data (and sensor data contained accordingly in the training data) may be from various sensors such as video, radar, LiDAR, ultrasonic, movement, acoustic, thermal image, etc., for example, sensor data concerning system states as well as configurations. The sensor data may be available in the form of (e.g., scalar) time series. 
     Specific embodiments may be used especially to train a machine learning system and to control a robot autonomously in order to accomplish different manipulation tasks under various scenarios. In particular, specific embodiments are usable for controlling and monitoring the execution of manipulation tasks, e.g., in assembly lines. For instance, they are able to be integrated seamlessly into a traditional GUI (graphical user interface) for a control process. 
     For example, in the case of a physical or chemical process, the trained neural stochastic differential equation may be used to predict sensor data e.g., a temperature or a material property, etc. 
     In such a context, specific embodiments may also be used for detecting anomalies. For example, an OOD (Out of Distribution) detection may be carried out for time series. To that end, for instance, with the aid of the trained neural stochastic differential equation, a mean and a covariance of a distribution of data points (e.g., sensor data) are predicted and it is determined whether measured sensor data follow this distribution. If the deviation is too great, this may be viewed as an indication that an anomaly is present and, for example, a robot device may be controlled accordingly (e.g., an assembly line may be brought to a stop). 
     The training data record may be constructed depending on the application case. Typically it includes a multitude of training trajectories which, for instance, contain the time characteristics of specific sensor data (temperature, speed, position, material property, . . . ). The training data records may be generated by experiments or by simulations. 
     According to one specific embodiment, the method is computer-implemented. 
     Although the present invention was presented and described specifically with reference to particular specific embodiments, it should be understood by those familiar with the field of expertise that numerous modifications may be made with respect to design and details without departing from the essence and scope of the present invention.