Main Content

deep.ode.options.ODE1

Neural ODE solver options for nonstiff differential equations using Euler method

Since R2025a

    Description

    A deep.ode.options.ODE1 object specifies options for the "ode1" solver of a neural ordinary differential equation (ODE) layer.

    The solver is based on the Euler method. Specify the options object using the SolverOptions property of a neuralODELayer object.

    Creation

    Create a neuralODELayer object and set the Solver property to "ode1". To set the solver options of the layer, use dot notation. For example, to set the step size to 0.01, use layer.SolverOptions.StepSize = 1, where layer is an instance of the neural ODE layer.

    In most cases, you do not need to create the deep.ode.options.ODE1 directly.

    Properties

    expand all

    Step size, specified as one of these values:

    • "auto" — Automatically determine the step size. When the neural network initializes, the layer updates this property to the numeric value used.

    • Positive scalar — Use the specified value as the step size.

    The deep.ode.options.ODE1 object stores this property as a character vector, single type, or double type.

    Data Types: single | double

    Method to compute gradients with respect to the initial conditions and parameters, specified as one of these values:

    • "direct" — Compute gradients by backpropagating through the operations undertaken by the numerical solver.

    • "adjoint" — Compute gradients by solving the associated adjoint ODE system.

    The dlaccelerate function does not support accelerating forward passes of networks with neural ODE layers with the GradientMode property set to "direct". To accelerate forward passes of networks with neural ODE layers, set the GradientMode property to "adjoint" or accelerate parts of your code that do not perform forward passes of the network.

    Warning

    When GradientMode is "adjoint", all layers in the Network property of the neural ODE layer must support acceleration. Otherwise, the software can return unexpected results.

    When GradientMode is "adjoint", the software traces the forward pass of the Network property of the neural ODE layer to determine the computation graph used for automatic differentiation. This tracing process can take some time and can end up recomputing the same trace. By optimizing, caching, and reusing the traces, the software can speed up the gradient computation.

    For more information on deep learning function acceleration, see Deep Learning Function Acceleration for Custom Training Loops.

    The deep.ode.options.ODE1 object stores this property as a character vector.

    Examples

    collapse all

    Create a neural ODE layer. Specify an ODE network containing a convolution layer followed by a tanh layer, a time interval of [0, 1], and that the layer uses the "ode1" solver.

    inputSize = [14 14 8];
    
    layersODE = [
        imageInputLayer(inputSize)
        convolution2dLayer(3,8,Padding="same")
        tanhLayer];
    
    netODE = dlnetwork(layersODE);
    
    tspan = [0 1];
    layer = neuralODELayer(netODE,tspan,Solver="ode1");

    Specify a step size of 1e-3 using the SolverOptions property of the layer.

    layer.SolverOptions.StepSize = 1e-3;

    View the layer solver options.

    layer.SolverOptions
    ans = 
      ODE1 with properties:
    
            StepSize: 1.0000e-03
        GradientMode: 'direct'
    
    

    Algorithms

    expand all

    Version History

    Introduced in R2025a