trajectory
trajectory
¶
Trajectory shape regularization losses.
TrajectoryLengthLoss
¶
Bases: ScalarWeightedLoss
Loss for trajectory length consistency.
Penalizes differences between predicted and ground truth trajectory lengths.
Initialize trajectory length loss.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weight
|
float
|
Weight for length loss |
0.001
|
action_key
|
str
|
Action key to compute length for |
required |
Source code in src/versatil/metrics/losses/trajectory.py
get_required_keys
¶
Get required target keys for trajectory length loss.
Returns:
| Type | Description |
|---|---|
set[str]
|
Set containing the action key this loss operates on |
forward
¶
Compute trajectory length loss.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions
|
dict[str, Tensor]
|
Dictionary with predicted actions |
required |
targets
|
dict[str, Tensor]
|
Dictionary with ground truth actions |
required |
is_pad
|
Tensor | None
|
Optional padding mask |
None
|
Returns:
| Type | Description |
|---|---|
LossOutput
|
LossOutput with length loss |
Source code in src/versatil/metrics/losses/trajectory.py
TrajectorySmoothness
¶
Bases: ScalarWeightedLoss
Loss for trajectory smoothness (acceleration regularization).
Initialize smoothness loss.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
weight
|
float
|
Weight for smoothness loss |
0.001
|
action_key
|
str
|
Action key to compute smoothness for |
required |
Source code in src/versatil/metrics/losses/trajectory.py
get_required_keys
¶
Get required target keys for trajectory smoothness loss.
Note: This loss only uses predictions, not targets, but we return the action key for consistency with other trajectory losses.
Returns:
| Type | Description |
|---|---|
set[str]
|
Empty set since this loss doesn't use targets |
Source code in src/versatil/metrics/losses/trajectory.py
forward
¶
Compute trajectory smoothness loss.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions
|
dict[str, Tensor]
|
Dictionary with predicted actions |
required |
targets
|
dict[str, Tensor]
|
Not used for smoothness |
required |
is_pad
|
Tensor | None
|
Optional padding mask |
None
|
Returns:
| Type | Description |
|---|---|
LossOutput
|
LossOutput with smoothness loss |