Common Components#
Base classes and common utilities for all loss modules.
|
A parent class for RL losses. |
|
Adds a random module to the list of modules that will be detected by |
Masked reduction#
Batches of padded sequences carry a per-position validity mask, and positions
marked invalid must not contribute to the loss. Every loss reduces through
LossModule._reduce_loss(), which reads that mask from the input according
to LossModule.loss_mask_key:
"auto"(the default) looks for each entry ofAUTO_LOSS_MASK_KEYSand ANDs the ones it finds, so a batch fromSliceSamplerwithpad_output=Trueis handled without any configuration. On data carrying none of those entries the reduction is unchanged.a
NestedKeyrestricts masking to that single entry.Nonedisables masking.
loss = PPOLoss(actor, critic)
loss.loss_mask_key = ("my_masks", "valid") # use this entry only
loss.loss_mask_key = None # reduce over every position
Masked positions are selected out rather than multiplied by zero, so a non-finite value at a masked position affects neither the loss nor the gradients.
Built-in immutable sequence. |
Value Estimators#
|
An abstract parent class for value function modules. |
|
Temporal Difference (TD(0)) estimate of advantage function. |
|
\(\infty\)-Temporal Difference (TD(1)) estimate of advantage function. |
|
TD(\(\lambda\)) estimate of advantage function. |
|
A class wrapper around the generalized advantage estimate functional. |
|
A class wrapper around V-Trace estimate functional. |
|
Multi-agent Generalized Advantage Estimator. |
|
Value function enumerator for custom-built estimators. |