train
#
Helpers for training parameters.
Classes:
-
AttributeConfig
–Configuration for how a potential's attributes should be trained.
-
ParameterConfig
–Configuration for how a potential's parameters should be trained.
-
Trainable
–A convenient wrapper around a tensor force field that gives greater control
AttributeConfig
pydantic-model
#
Bases: BaseModel
Configuration for how a potential's attributes should be trained.
Fields:
ParameterConfig
pydantic-model
#
Bases: AttributeConfig
Configuration for how a potential's parameters should be trained.
Fields:
scales
pydantic-field
#
The scales to apply to each parameter, e.g. 'k': 1.0, 'length': 1.0, 'epsilon': 1.0.
limits
pydantic-field
#
The min and max values to clamp each parameter within, e.g. 'k': (0.0, None), 'angle': (0.0, pi), 'epsilon': (0.0, None), where none indicates no constraint.
include
pydantic-field
#
The keys (see smee.TensorPotential.parameter_keys
for details) corresponding to specific parameters to be trained. If None
, all parameters will be trained.
exclude
pydantic-field
#
The keys (see smee.TensorPotential.parameter_keys
for details) corresponding to specific parameters to be excluded from training. If None
, no parameters will be excluded.
Trainable
#
Trainable(
force_field: TensorForceField,
parameters: dict[str, ParameterConfig],
attributes: dict[str, AttributeConfig],
)
A convenient wrapper around a tensor force field that gives greater control over how parameters should be trained.
This includes imposing limits on the values of parameters, scaling the values so parameters passed to the optimizer have similar magnitudes, and freezing parameters so they are not updated during training.
parameters: Configure which parameters to train.
attributes: Configure which attributes to train.
Methods:
-
to_values
–Returns unfrozen parameter and attribute values as a flat tensor.
-
to_force_field
–Returns a force field with the parameters and attributes set to the given
-
clamp
–Clamps the given values to the configured min and max values.
Source code in descent/train.py
to_values
#
Returns unfrozen parameter and attribute values as a flat tensor.
Source code in descent/train.py
to_force_field
#
to_force_field(values_flat: Tensor) -> TensorForceField
Returns a force field with the parameters and attributes set to the given values.
Parameters:
-
values_flat
(Tensor
) –A flat tensor of parameter and attribute values. See
to_values
for the expected shape and ordering.
Source code in descent/train.py
clamp
#
Clamps the given values to the configured min and max values.