neuromancer.dynamics.integrators module

Single-step integrators for first-order nonautomonomous ODEs

class neuromancer.dynamics.integrators.BasicSDEIntegrator(block)[source]

Bases: Integrator

Integrator (from TorchSDE) for basic/explicit SDE case where drift (f) and diffusion (g) terms are defined Returns a single tensor of size (t, batch_size, state_size).

Please see https://github.com/google-research/torchsde/blob/master/torchsde/_core/sdeint.py Currently only supports Euler integration. Choice of integration method is dependent on integral type (Ito/Stratanovich) and drift/diffusion terms

integrate(x, t)[source]

x is the initial datastate of size (batch_size, state_size) t is the time-step vector over which to integrate

class neuromancer.dynamics.integrators.DiffEqIntegrator(block, interp_u=None, h=0.001, method='euler')[source]

Bases: Integrator

integrate(x, *args)[source]
class neuromancer.dynamics.integrators.Euler(block, interp_u=None, h=1.0)[source]

Bases: Integrator

integrate(x, *args)[source]
class neuromancer.dynamics.integrators.Euler_Trap(block, interp_u=None, h=1.0)[source]

Bases: Integrator

integrate(x, *args)[source]
Parameters:

x – (torch.Tensor, shape=[batchsize, SysDim])

Return x_{t+1}:

(torch.Tensor, shape=[batchsize, SysDim])

class neuromancer.dynamics.integrators.Integrator(block, interp_u=None, h=1.0)[source]

Bases: Module, ABC

forward(x, *args)[source]

This function needs x only for autonomous systems. x is 2D. It needs x and u for nonautonomous system w/ online interpolation. x and u are 2D tensors.

abstract integrate(x, *args)[source]
reg_error()[source]
class neuromancer.dynamics.integrators.LatentSDEIntegrator(block, dt=0.01, method='euler', adjoint=False)[source]

Bases: Integrator

Integrator (from TorchSDE) for LatentSDE case. Please see https://github.com/google-research/torchsde/blob/master/examples/latent_sde_lorenz.py for more information. Integration here takes place in the latent space produced by the first-stage (encoding process) of the LatentSDE_Encoder block Note that torchsde.sdeint() is called, like in BasicSDEIntegrator, and thus the output of integrate() is a single tensor of size (t, batch_size, latent_size) In this case we also set logqp to True such that log ratio penalty is also returned. PLease see: https://github.com/google-research/torchsde/blob/master/torchsde/_core/sdeint.py

integrate(x)[source]
class neuromancer.dynamics.integrators.LeapFrog(block, interp_u=None, h=1.0)[source]

Bases: Integrator

integrate(X, *args)[source]
Parameters:

X – (torch.Tensor, shape=[batchsize, 2*SysDim]) where X[:, :SysDim] = x_t and X[:, SysDim:] = dot{x}_t

Return X_{t+1}:

(torch.Tensor, shape=[batchsize, 2*SysDim]) where X_{t+1}[:, :SysDim] = x_{t+1} and X_{t+1}[:, SysDim:] = dot{x}_{t+1}

class neuromancer.dynamics.integrators.Luther(block, interp_u=None, h=1.0)[source]

Bases: Integrator

integrate(x, *args)[source]
class neuromancer.dynamics.integrators.MultiStep_PredictorCorrector(block, interp_u=None, h=1.0)[source]

Bases: Integrator

integrate(x, *args)[source]
Parameters:

x – (torch.Tensor, shape=[batchsize, nsteps, SysDim]) where x[0:1, :, :] = x_{t-3}, x[1:2, :, :] = x_{t-2}, x[2:3, :, :] = x_{t-1}, x[3:4, :, :] = x_{t}

Return x_{t+1}:

(torch.Tensor, shape=[batchsize, SysDim])

class neuromancer.dynamics.integrators.RK2(block, interp_u=None, h=1.0)[source]

Bases: Integrator

integrate(x, *args)[source]
class neuromancer.dynamics.integrators.RK4(block, interp_u=None, h=1.0)[source]

Bases: Integrator

integrate(x, *args)[source]
class neuromancer.dynamics.integrators.RK4_Trap(block, interp_u=None, h=1.0)[source]

Bases: Integrator

predictor-corrector integrator for dx = f(x) predictor: explicit RK4 corrector: implicit trapezoidal rule

integrate(x, *args)[source]
class neuromancer.dynamics.integrators.Runge_Kutta_Fehlberg(block, interp_u=None, h=1.0)[source]

Bases: Integrator

The Runge–Kutta–Fehlberg method has two methods of orders 5 and 4. Therefore, we can calculate the local truncation error to determine if current time step size is suitable or not. # https://en.wikipedia.org/wiki/Runge%E2%80%93Kutta_methods#Adaptive_Runge%E2%80%93Kutta_methods

integrate(x, *args)[source]
Parameters:

x – (torch.Tensor, shape=[batchsize, SysDim])

Return x_{t+1}:

(torch.Tensor, shape=[batchsize, SysDim])

class neuromancer.dynamics.integrators.Yoshida4(block, interp_u=None, h=1.0)[source]

Bases: Integrator

integrate(X, *args)[source]
Parameters:

X – (torch.Tensor, shape=[batchsize, 2*SysDim]) where X[:, :SysDim] = x_t and X[:, SysDim:] = dot{x}_t

Return X_{t+1}:

(torch.Tensor, shape=[batchsize, 2*SysDim]) where X_{t+1}[:, :SysDim] = x_{t+1} and X_{t+1}[:, SysDim:] = dot{x}_{t+1}

neuromancer.dynamics.integrators.make_norm(state)[source]
neuromancer.dynamics.integrators.rms_norm(tensor)[source]