nvalchemi.training.LinearWeight#
- pydantic model nvalchemi.training.LinearWeight[source]#
Loss weight that ramps linearly from
starttoend.LinearWeightinterpolates a component’s weight along a straight line: it returnsstartat schedule index0andendat indexnum_steps, moving proportionally in between. Use it to phase a loss term in or out gradually – for example warming a force or stress term up from0over the first few thousand updates, or annealing an auxiliary term down toward the end of training. The schedule index is the global step whenper_epoch=False(default) and the epoch whenper_epoch=True, and the value is clamped tostartfor index<= 0and toendfor index>= num_steps.Examples
>>> from nvalchemi.training.losses import LinearWeight >>> w = LinearWeight(start=0.0, end=1.0, num_steps=10) >>> w(step=0, epoch=0), w(step=5, epoch=0), w(step=100, epoch=0) (0.0, 0.5, 1.0)
Advance the ramp once per epoch instead of per step:
>>> w = LinearWeight(start=0.2, end=1.0, num_steps=10, per_epoch=True)
Notes
num_stepsmust be strictly positive. Instances are frozen (immutable) per the shared_BaseWeightScheduleconfig.