NEML2 1.4.0
|
A thin wrapper around neml2::Model
Public Member Functions | |
dict[str, Model] | dependency (self) |
TensorValue | get_parameter (self, str arg0) |
tensors.LabeledAxis | input_axis (self) |
tensors.TensorType | input_type (self, tensors.LabeledAxisAccessor variable) |
dict[str, TensorValue] | named_buffers (self) |
dict[str, TensorValue] | named_parameters (self) |
dict[str, Model] | named_submodels (self) |
tensors.LabeledAxis | output_axis (self) |
tensors.TensorType | output_type (self, tensors.LabeledAxisAccessor variable) |
None | reinit (self, tuple[int,...] batch_shape=(), int deriv_order=0, torch.device device=..., torch.dtype dtype=...) |
None | set_parameter (self, str arg0, tensors.Tensor arg1) |
None | set_parameters (self, dict[str, tensors.Tensor] arg0) |
typing.Any | value (self, typing.Any arg0) |
tuple | value_and_dvalue (self, typing.Any arg0) |
bool | is_AD_enabled (self) |
str | name (self) |
str | type (self) |
dict[str, Model] dependency | ( | self | ) |
Get the dictionary describing this model's dependency information, if any.
TensorValue get_parameter | ( | self, | |
str | arg0 ) |
Get a model parameter given its name
tensors.LabeledAxis input_axis | ( | self | ) |
Input axis of the model. The axis contains information on variable names and their associated slicing indices.
tensors.TensorType input_type | ( | self, | |
tensors.LabeledAxisAccessor | variable ) |
Introspect the underlying tensor type of an input variable. @returns tensors.TensorType
bool is_AD_enabled | ( | self | ) |
Whether automatic differentiation is enabled for this model. This property cannot be modified once the model is created. Use the `enable_AD` option of base.load_model or base.get_model to control this property.
str name | ( | self | ) |
Name of the model
dict[str, TensorValue] named_buffers | ( | self | ) |
Get the model buffers. The keys of the returned dictionary are the buffers' names.
dict[str, TensorValue] named_parameters | ( | self | ) |
Get the model parameters. The keys of the returned dictionary are the parameters' names.
dict[str, Model] named_submodels | ( | self | ) |
Get the sub-models registered to this model
tensors.LabeledAxis output_axis | ( | self | ) |
Input axis of the model. The axis contains information on variable names and their associated slicing indices.
tensors.TensorType output_type | ( | self, | |
tensors.LabeledAxisAccessor | variable ) |
Introspect the underlying tensor type of an output variable. @returns tensors.TensorType
None reinit | ( | self, | |
tuple[int, ...] | batch_shape = (), | ||
int | deriv_order = 0, | ||
torch.device | device = ..., | ||
torch.dtype | dtype = ... ) |
(Re)initialize the model with given batch shape, derivative order, device, and dtype. :param batch_shape: Batch shape used to allocate input, output, and derivative storage :param deriv_order: An integer ranging from 0-2. When set to 0, only the output storage will be allocated; when set to 1, both the output and the first derivative storage are allocated; when set to 2, the second derivative storage is additionally allocated. :param device: Device on which the model will be evaluated. All parameters, buffers, and custom data are synced to the given device. :param dtype: Floating point scalar type used throughout the model.
None set_parameter | ( | self, | |
str | arg0, | ||
tensors.Tensor | arg1 ) |
Set the value for a model parameter
None set_parameters | ( | self, | |
dict[str, tensors.Tensor] | arg0 ) |
Set the values for multiple model parameters
str type | ( | self | ) |
Type of the model
typing.Any value | ( | self, | |
typing.Any | arg0 ) |
Evaluate the model with given input and return the output. Note that the input can either be of type torch.Tensor, tensors.Tensor, or tensors.LabeledVector. The returned output will be of the covariant type of the input.
tuple value_and_dvalue | ( | self, | |
typing.Any | arg0 ) |
Evaluate the model with given input and return the output as well the first derivative. Note that the input can either be of type torch.Tensor, tensors.Tensor, or tensors.LabeledVector. The returned output and derivative will be of the covariant type of the input.