nvalchemi.training.ConstantWeight#

pydantic model nvalchemi.training.ConstantWeight[source]#

Time-invariant loss weight that returns value at every update.

ConstantWeight is the simplest LossWeightSchedule: it ignores both the global step and the epoch and always yields value. Reach for it when a component’s contribution is fixed but you still want to express the weight as a schedule object – for instance to keep a uniform type across a ComposedLossFunction’s weights sequence, or to scale a leaf loss with the schedule * leaf operator. A bare float weight behaves identically; the schedule form is mostly for symmetry and serialization.

Examples

>>> from nvalchemi.training.losses import ConstantWeight
>>> w = ConstantWeight(value=2.5)
>>> w(step=0, epoch=0), w(step=1000, epoch=9)
(2.5, 2.5)

Multiply a leaf loss to build a weighted component:

>>> weighted = ConstantWeight(value=10.0) * ForceMSELoss()

Notes

Instances are frozen (immutable) per the shared _BaseWeightSchedule config, so a schedule can be safely reused across components.

field value: float [Required]#

Constant weight value.