ChaoticNDETools
Documentation for ChaoticNDETools.
ChaoticNDETools.ChaoticNDE
ChaoticNDETools.NablaSkipConnection
ChaoticNDETools.ParSkipConnection
ChaoticNDETools.Device
ChaoticNDETools.average_forecast_length
ChaoticNDETools.forecast_horizon_datagen
ChaoticNDETools.forecast_lengths
ChaoticNDETools.forecast_δ
ChaoticNDETools.gpuoff
ChaoticNDETools.gpuon
ChaoticNDETools.set_params!
ChaoticNDETools.trajectory
ChaoticNDETools.∂x_PBC
ChaoticNDETools.∂x²_PBC
ChaoticNDETools.∂x⁴_PBC
ChaoticNDETools.ChaoticNDE
— TypeChaoticNDE{P,R,A,K} <: AbstractChaoticNDEModel
Model for setting up and training Chaotic Neural Differential Equations.
Fields:
p
parameter vectorprob
DEProblemalg
Algorithm to use for thesolve
commandkwargs
any additional keyword arguments that should be handed over (e.g.sensealg
)device
the device the model is running on, eitherCPUDevice
orCUDADevice
, used for dispatiching ifArrays
orCuArrays
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.
ChaoticNDETools.NablaSkipConnection
— TypeNablaSkipConnection
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
ChaoticNDETools.ParSkipConnection
— TypeParSkipConnection(layer, connection)
A version of SkipConnection that is paramaterized with one single parameter, thus the output is connection(w .* layer(input), input)
ChaoticNDETools.Device
— MethodDevice(; 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.
ChaoticNDETools.average_forecast_length
— Methodaverage_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
`)
ChaoticNDETools.forecast_horizon_datagen
— Functionforecast_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
ChaoticNDETools.forecast_lengths
— Methodforecast_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
`)
ChaoticNDETools.forecast_δ
— Methodforecast_δ(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
ChaoticNDETools.gpuoff
— Methodgpuoff()
Manually toggle GPU use off
ChaoticNDETools.gpuon
— Methodgpuon()
Manually toggle GPU use on (if available)
ChaoticNDETools.set_params!
— Methodset_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.
ChaoticNDETools.trajectory
— Methodtrajectory(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.
ChaoticNDETools.∂x_PBC
— Method∂x_PBC(n::Integer, dx::T)
2nd order central finite difference matrix for 1d domains with periodic boundary conditions
ChaoticNDETools.∂x²_PBC
— Method∂x²_PBC(n::Integer, dx::T)
2nd order central finite difference matrix of the second derivative for 1d domains with periodic boundary conditions
ChaoticNDETools.∂x⁴_PBC
— Method∂x⁴_PBC(n::Integer, dx::T)
4th derivative finite difference matrix with periodic boundary conditions