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:
-
cols(list[str]) -
scales(dict[str, float]) -
limits(dict[str, tuple[float | None, float | None]]) -
regularize(dict[str, float])
Validators:
-
_validate_keys
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.
regularize
pydantic-field
#
The regularization strength to apply to each parameter, e.g. 'k': 0.01, 'epsilon': 0.001. Parameters not listed are not regularized.
ParameterConfig
pydantic-model
#
Bases: AttributeConfig
Configuration for how a potential's parameters should be trained.
Fields:
-
cols(list[str]) -
scales(dict[str, float]) -
limits(dict[str, tuple[float | None, float | None]]) -
regularize(dict[str, float]) -
include(PotentialKeyList | None) -
exclude(PotentialKeyList | None)
Validators:
-
_validate_keys -
_validate_include_exclude
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.
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.
regularize
pydantic-field
#
The regularization strength to apply to each parameter, e.g. 'k': 0.01, 'epsilon': 0.001. Parameters not listed are not regularized.
Trainable
#
Trainable(
force_field: TensorForceField,
parameters: dict[str, ParameterConfig],
attributes: dict[str, AttributeConfig],
vsites: ParameterConfig | None = None,
)
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.
vsites: Configure which vsite parameters 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.
Attributes:
-
regularized_idxs(Tensor) –The indices (within the tensor returned by to_values)
-
regularization_weights(Tensor) –The regularization weights for parameters/attributes to regularize.
Source code in descent/train.py
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 | |
regularized_idxs
property
#
The indices (within the tensor returned by to_values) of parameters/attributes to regularize.
regularization_weights
property
#
The regularization weights for parameters/attributes to regularize.
to_values
#
Returns unfrozen parameter and attribute values as a flat tensor.
Source code in descent/train.py
to_force_field
#
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_valuesfor the expected shape and ordering.
Source code in descent/train.py
clamp
#
Clamps the given values to the configured min and max values.