ChaoticNDETools

Documentation for ChaoticNDETools.

ChaoticNDETools.ChaoticNDEType
ChaoticNDE{P,R,A,K} <: AbstractChaoticNDEModel

Model for setting up and training Chaotic Neural Differential Equations.

Fields:

  • p parameter vector
  • prob DEProblem
  • alg Algorithm to use for the solve command
  • kwargs any additional keyword arguments that should be handed over (e.g. sensealg)
  • device the device the model is running on, either CPUDevice or CUDADevice, used for dispatiching if Arrays or CuArrays are used

Constructors

  • ChaoticNDE(prob; alg=Tsit5(), kwargs...)
  • ChaoticNDE(model::ChaoticNDE; alg=model.alg, kwargs...) remake the model with different kwargs and solvers

Input / call

An instance of the model is called with a trajectory pair (t,x) in t are the timesteps that NDE is integrated for and x is a trajectory N x ... x N_t in which x[:, ... , 1] is taken as the initial condition.

source
ChaoticNDETools.NablaSkipConnectionType

NablaSkipConnection

With the input $x$, passes $w * (∇ * x) + (1 - |w|) * x$ , where $w\in\mathbb{R}, w\in [0,1]$. Here $\Nabla$ is a finite difference derivative matrix

source
ChaoticNDETools.ParSkipConnectionType

ParSkipConnection(layer, connection)

A version of SkipConnection that is paramaterized with one single parameter, thus the output is connection(w .* layer(input), input)

source
ChaoticNDETools.DeviceMethod
Device(; gpu::Union{Nothing, Bool}=nothing)

Initializes the device that is used. Returns either CPUDevice or CUDADevice. If no gpu keyword argument is given, it determines automatically if a GPU is available.

source
ChaoticNDETools.average_forecast_lengthMethod
average_forecast_length(predict, valid::NODEDataloader,N_t=300; λmax=0, mode="norm")

Returns the average forecast length on a NODEDataloader set (should be valid or test set) given a (t, u0) -> prediction function. N_t is the length of each forecast, has to be larger than the expected forecast length. If a λmax is given, the results are scaled with it (and dt`)

source
ChaoticNDETools.forecast_horizon_datagenFunction
forecast_horizon_datagen(predict, ground_truth_predict, u0, t, N_t=300, λ_max=0, mode="norm", threshold=0.4)

Returns the forecast horizon, but also generates the ground truth data with a (t,u0) -> data function. Use this in cases in which the forecast horizon might be longer than the valid set

source
ChaoticNDETools.forecast_lengthsMethod
forecast_lengths(model, t::AbstractArray{T,1}, input_data::AbstractArray{T,S}, N_t::Integer=300; λ_max=0, mode="norm", threshold=0.4, output_data::Union{Nothing, AbstractArray{T,S}}=nothing)

Returns the forecast lengths of predictions on a NODEDataloader set (should be valid or test set) given a (t, u0) -> prediction function. N_t is the length of each forecast, has to be larger than the expected forecast length. If a λmax is given, the results are scaled with it (and dt`)

source
ChaoticNDETools.forecast_δMethod
forecast_δ(prediction::AbstractArray{T,N}, truth::AbstractArray{T,N}, mode::String="both") where {T,N}

Assumes that the last dimension of the input arrays is the time dimension and N_t long. Returns an N_t long array, judging how accurate the prediction is.

Supported modes:

  • "mean": mean between the arrays
  • "maximum": maximum norm
  • "norm": normalized, similar to the metric used in Pathak et al
source
ChaoticNDETools.set_params!Method
set_params!(m::ChaoticNDE{P,R,A,K,D}, p::P) where {P,R,A,K,D}

Sets p as the parameters of model m. Used e.g. when loading parameter from trained models.

source
ChaoticNDETools.trajectoryMethod
trajectory(m::ChaoticNDE, tspan, u0; alg=nothing, kwargs...)

Solves the model m, returns a SciML solution object. All keyword arguments are directly forwarded to the differential equation solver.

source
ChaoticNDETools.∂x_PBCMethod
∂x_PBC(n::Integer, dx::T)

2nd order central finite difference matrix for 1d domains with periodic boundary conditions

source
ChaoticNDETools.∂x²_PBCMethod
∂x²_PBC(n::Integer, dx::T)

2nd order central finite difference matrix of the second derivative for 1d domains with periodic boundary conditions

source