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],
)
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.
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
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 | |
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.