🧠Model Wrappers API¶
The node_fdm.models namespace provides the high-level PyTorch nn.Module wrappers that encapsulate the Neural ODE logic.
These classes serve as the core mathematical engine of the framework. They handle the forward pass integration, the batch processing of trajectories, and the orchestration of the various layers defined in your architecture.
📘 Class Reference¶
Flight Dynamics Model (Base)¶
The primary wrapper used during training. It manages the input encoding, connects to the ODE solver, and handles state reconstruction.
flight_dynamics_model
¶
Neural flight dynamics model assembled from architecture layers.
FlightDynamicsModel
¶
Bases: Module
Compute state derivatives using a layered flight dynamics architecture.
Source code in src/node_fdm/models/flight_dynamics_model.py
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 | |
__init__(architecture, stats_dict, model_cols, model_params=(2, 1, 48))
¶
Initialize the model with architecture definition and statistics.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
architecture
|
Sequence[Any]
|
Iterable of layer definitions |
required |
stats_dict
|
Dict[Any, Dict[str, float]]
|
Mapping from column to normalization/denormalization statistics. |
required |
model_cols
|
Tuple[Any, Any, Any, Any, Any]
|
Tuple of model column groups (state, control, env, env_extra, derivatives). |
required |
model_params
|
Sequence[int]
|
Sequence defining backbone depth, head depth, and hidden width. |
(2, 1, 48)
|
Source code in src/node_fdm/models/flight_dynamics_model.py
create_structured_layer(input_cols, output_cols, layer_class=StructuredLayer)
¶
Build a structured layer with normalization and denormalization stats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_cols
|
Sequence[Any]
|
Columns consumed by the layer. |
required |
output_cols
|
Sequence[Any]
|
Columns produced by the layer. |
required |
layer_class
|
Any
|
Layer implementation to instantiate. |
StructuredLayer
|
Returns:
| Type | Description |
|---|---|
Module
|
Configured structured layer instance. |
Source code in src/node_fdm/models/flight_dynamics_model.py
forward(x, u_t, e_t)
¶
Compute state derivatives for the current batch.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
Tensor
|
State tensor. |
required |
u_t
|
Tensor
|
Control tensor interpolated at current time. |
required |
e_t
|
Tensor
|
Environment tensor interpolated at current time. |
required |
Returns:
| Type | Description |
|---|---|
Tensor
|
Tensor of state derivatives assembled from architecture outputs. |
Source code in src/node_fdm/models/flight_dynamics_model.py
reset_history()
¶
Reset internal history buffers.
Clears stored layer outputs used for debugging or analysis between runs.
Batch Neural ODE¶
The core utility responsible for solving the system of differential equations over batches of time sequences. It interfaces with the numerical solvers (Euler, RK4).
batch_neural_ode
¶
Batch-compatible Neural ODE wrapper that interpolates inputs over time.
BatchNeuralODE
¶
Bases: Module
Wrap a neural ODE with batched control and environment inputs.
Source code in src/node_fdm/models/batch_neural_ode.py
__init__(model, u_seq, e_seq, t_grid)
¶
Initialize the ODE wrapper and reset model history.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model
|
Module
|
Base neural ODE model taking |
required |
u_seq
|
Tensor
|
Control inputs over time with shape |
required |
e_seq
|
Tensor
|
Environment inputs over time with shape |
required |
t_grid
|
Tensor
|
Monotonic time grid corresponding to |
required |
Source code in src/node_fdm/models/batch_neural_ode.py
forward(t, x)
¶
Evaluate the ODE dynamics at time t with linear interpolation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
t
|
Tensor
|
Scalar tensor containing the evaluation time. |
required |
x
|
Tensor
|
Current state tensor. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Model output of the wrapped dynamics at time |
Source code in src/node_fdm/models/batch_neural_ode.py
Production Model¶
An optimized wrapper designed strictly for inference environments. It streamlines the forward pass by removing training-specific hooks and overhead.
flight_dynamics_model_prod
¶
Production-ready flight dynamics model loader and evaluator.
FlightDynamicsModelProd
¶
Bases: Module
Load pretrained flight dynamics layers and expose an evaluation interface.
Source code in src/node_fdm/models/flight_dynamics_model_prod.py
14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 | |
__init__(model_path)
¶
Initialize and load pretrained layers from a model directory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
model_path
|
Any
|
Path-like pointing to the directory containing checkpoints and meta.json. |
required |
Source code in src/node_fdm/models/flight_dynamics_model_prod.py
create_structured_layer(input_cols, output_cols, layer_class=StructuredLayer)
¶
Build a structured layer with normalization and denormalization stats.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_cols
|
Sequence[Any]
|
Columns consumed by the layer. |
required |
output_cols
|
Sequence[Any]
|
Columns produced by the layer. |
required |
layer_class
|
Any
|
Layer implementation to instantiate. |
StructuredLayer
|
Returns:
| Type | Description |
|---|---|
Module
|
Configured structured layer instance. |
Source code in src/node_fdm/models/flight_dynamics_model_prod.py
forward(vect_dict)
¶
Run a forward pass through all layers.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
vect_dict
|
dict
|
Mapping from column identifiers to tensors. |
required |
Returns:
| Type | Description |
|---|---|
dict
|
Updated mapping with newly computed columns. |
Source code in src/node_fdm/models/flight_dynamics_model_prod.py
load_layer_checkpoint(layer_name)
¶
Load checkpoint for a given layer.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
layer_name
|
str
|
Name of the layer whose weights should be loaded. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
Loaded checkpoint dictionary. |