dynadojo.systems.snn.SNNSystem#
- class dynadojo.systems.snn.SNNSystem#
Bases:
LDSystem
Methods
__init__
([latent_dim, embed_dim, IND_range, ...])Initialize the class.
calc_control_cost
(control)Calculates the L2 norm / dimension of every vector in the control
calc_dynamics
(t, x)Calculates the dynamics for the system.
calc_error
(x, y)Returns the MSE error normalized by the embedded dimension.
make_data
(init_conds, control, timesteps[, ...])Uses the
calc_dynamics()
method to generate data.make_init_conds
(n[, in_dist])Uniformly samples embedded-dimensional points from an inside or outside distribution
Attributes
The controller matrix.
The embedded dimension for the system.
The embedder matrix.
The latent dimension for the system.
The random seed for the system.
- __init__(latent_dim=2, embed_dim=4, IND_range=(0, 1), OOD_range=(-1, 0), seed=None, **kwargs)#
Initialize the class.
- Parameters:
latent_dim (int, optional) – Dimension of the latent space. Defaults to 2. Can set to large values.
embed_dim (int, optional) – Embedded dimension of the system. Defaults to 2. Can set to large values. Should be at least as large as latent_dim.
A_eigval_range (tuple, optional) – Range for eigenvalues of the matrix A. Defaults to (-1, 1). Recommended to keep this value between -1 and 1 for stable systems.
A_eigvec_range (tuple, optional) – Range for eigenvectors of the matrix A. Defaults to (-1, 1).
**kwargs – Additional keyword arguments.
- calc_control_cost(control)#
Calculates the L2 norm / dimension of every vector in the control
- Parameters:
control (ndarray) –
- Return type:
float
- calc_dynamics(t, x)#
Calculates the dynamics for the system. Your class must implement this.
- calc_error(x, y)#
Returns the MSE error normalized by the embedded dimension.
- Return type:
float
- property controller#
The controller matrix. For example, in a system \(\dot{x} = Ax + Bu\), the controller is \(B\).
- property embed_dim#
The embedded dimension for the system.
- property embedder#
The embedder matrix. An invertible map from the latent space to the embedding space.
- property latent_dim#
The latent dimension for the system.
- make_data(init_conds, control, timesteps, noisy=False)#
Uses the
calc_dynamics()
method to generate data. Mathematically, data is generated like \(\dot{x} = f(x) + Bu\). Where \(f(x)\) is given bycalc_dynamics()
.- Parameters:
init_conds (numpy.ndarray) – (n, embed_dim) Initial conditions matrix.
control (numpy.ndarray) – (n, timesteps, embed_dim) Controls tensor.
timesteps (int) – Timesteps per training trajectory (per action horizon).
noisy (bool, optional) – If True, add noise to trajectories. Defaults to False. If False, no noise is added.
- Returns:
(n, timesteps, embed_dim) Trajectories tensor.
- Return type:
numpy.ndarray
- make_init_conds(n, in_dist=True)#
Uniformly samples embedded-dimensional points from an inside or outside distribution
Note
Systems developers determine what counts as in vs out-of-distribution. DynaDojo doesn’t provide any verification that this distinction makes sense or even exists. See
LDSystem
for a principled example.- Parameters:
n (int) – Number of initial conditions.
in_dist (bool, optional) – If True, generate in-distribution initial conditions. Defaults to True. If False, generate out-of-distribution initial conditions.
- Returns:
(n, embed_dim) Initial conditions matrix.
- Return type:
numpy.ndarray
- property seed#
The random seed for the system.