dynadojo.baselines.dnn.DNN#
- class dynadojo.baselines.dnn.DNN#
Bases:
AbstractAlgorithm
Deep Neural Network (DNN). Contains 5 hidden layers with 30 neurons each.
Methods
__init__
(embed_dim, timesteps[, ...])Initialize the class.
act
(x, **kwargs)Determines the control for each action horizon.
fit
(x[, epochs, verbose])Fits the algorithm on a tensor of trajectories.
predict
(x0, timesteps, **kwargs)Predict how initial conditions matrix evolves over a given number of timesteps.
Attributes
The embedded dimension of the dynamics.
The maximum control cost.
The random seed for the algorithm.
The timesteps per training trajectory.
- __init__(embed_dim, timesteps, max_control_cost=0, activation='relu', seed=None, **kwargs)#
Initialize the class.
- Parameters:
embed_dim (int) – The embedded dimension of the system. Recommended to keep embed dimension small (e.g., <10).
timesteps (int) – The timesteps of the training trajectories. Must be greater than 2.
activation (str, optional) – The activation function used in the hidden layers. See
tensorflow
documentation for more details on acceptable activations. Defaults torelu
.max_control_cost (float, optional) – Ignores control, so defaults to 0.
**kwargs (dict, optional) – Additional keyword arguments
- act(x, **kwargs)#
Determines the control for each action horizon. control.
- Parameters:
x (numpy.ndarray) – (n, timesteps, embed_dim) Trajectories tensor.
**kwargs – Additional keyword arguments.
- Returns:
(n, timesteps, embed_dim) controls tensor.
- Return type:
numpy.ndarray
- property embed_dim#
The embedded dimension of the dynamics.
- fit(x, epochs=2000, verbose=0, **kwargs)#
Fits the algorithm on a tensor of trajectories.
- Parameters:
x (np.ndarray) – (n, timesteps, embed_dim) Trajectories tensor.
**kwargs – Additional keyword arguments.
- property max_control_cost#
The maximum control cost.
- predict(x0, timesteps, **kwargs)#
Predict how initial conditions matrix evolves over a given number of timesteps.
Note
The timesteps argument can differ from the ._timesteps attribute. This allows algorithms to train on a dataset of a given size and then predict trajectories of arbitrary lengths.
Note
The first coordinate of each trajectory should match the initial condition x0.
- Parameters:
x0 (np.ndarray) – (n, embed_dim) initial conditions matrix
timesteps (int) – timesteps per predicted trajectory
**kwargs – Additional keyword arguments.
- Returns:
(n, timesteps, embed_dim) trajectories tensor
- Return type:
np.ndarray
- property seed#
The random seed for the algorithm.
- property timesteps#
The timesteps per training trajectory.