Model
Model(sizes=None, spectral_norm=True, activation=None, full=False, feature_norm=None, batch_norm=None, perturb_fn=None)
Bases: Module, ABC
Abstract model wrapper with optional input normalization.
Parameters:
-
sizes(list of int or None, default:None) –Hidden-layer widths. If
None, defaults to[128, 128, 128]. -
spectral_norm(bool, default:True) –Whether to apply spectral normalization to hidden layers.
-
activation(Module or None, default:None) –Hidden activation. If
None, defaults toELU. -
full(bool, default:False) –If
True, also apply spectral normalization to the final layer. -
feature_norm((None, str), default:None) –Optional feature-wise normalization mode, for example
"zscore"or"zscore-nocenter". -
batch_norm((None, str), default:None) –Optional batch-wise normalization mode, for example
"zscore"or"zscore-notime". -
perturb_fn(callable or None, default:None) –Optional post-processing function applied to model outputs.
Attributes:
-
net_(Module or None) –Wrapped network instantiated during
init_model. -
Ndim_(int or None) –Inferred spatial dimension set during
init_model.
dim_output()
abstractmethod
Return output dimension of the wrapped network.
Returns:
-
int–Output dimension expected from
net_.
dim_spatial()
Return number of spatial dimension of the wrapped network.
Returns:
-
int–Number of spatial dimension in net_ (by definition the first dimensions).
evaluate_net(x)
Evaluate network with dimension selection, scaling, and transform.
Parameters:
-
x(Tensor) –Full input tensor including spatial coordinates and, by convention, time in the last coordinate.
Returns:
-
Tensor–Final model output after preprocessing and postprocessing.
init_model(X, generator=None)
Initialize network and normalization statistics from batched data.
Parameters:
-
X(Tensor) –Batched inputs with last dimension corresponding to features. By convention, time is stored in the last coordinate.
-
generator(Generator or None, default:None) –Optional RNG for reproducible weight initialization.
Returns:
-
Model–The initialized model instance.
is_autonomous()
abstractmethod
Return whether the model is autonomous in time.
Returns:
-
bool–Trueif the model ignores the time coordinate.
is_gradient()
abstractmethod
Return whether the model uses a gradient-based output.
Returns:
-
bool–Truefor gradient models, otherwiseFalse.