gripper
gripper
¶
Gripper action loss and shared gripper metadata resolution.
GripperLoss
¶
Bases: BaseLoss
Loss for gripper action prediction (binary or continuous).
Initialize gripper loss.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Action key for gripper |
required |
actions_metadata
|
dict[str, ActionMetadata]
|
Dict of metadata of the action space |
required |
bce_weight
|
float
|
Weight for binary cross entropy (binary gripper) |
0.005
|
mse_weight
|
float
|
Weight for MSE loss (continuous gripper) |
0.0
|
pos_weight
|
Tensor | float | None
|
Optional positive class weight for BCE |
None
|
Source code in src/versatil/metrics/losses/gripper.py
requires_action_space_targets
property
¶
Whether the loss needs action-space metadata for BCE targets.
set_weights
¶
Setter that updates the weight scalar coefficients.
Source code in src/versatil/metrics/losses/gripper.py
get_required_keys
¶
Get required target keys for gripper loss.
Returns:
| Type | Description |
|---|---|
set[str]
|
Set containing the gripper action key |
forward
¶
Compute gripper loss.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
predictions
|
dict[str, Tensor]
|
Dictionary with 'gripper_action' key |
required |
targets
|
dict[str, Tensor]
|
Dictionary with ground truth gripper actions |
required |
is_pad
|
Tensor | None
|
Optional padding mask |
None
|
Returns:
| Type | Description |
|---|---|
LossOutput
|
LossOutput with gripper loss |
Source code in src/versatil/metrics/losses/gripper.py
resolve_gripper_metadata
¶
Resolve gripper type and binary range from action-space metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Gripper action key to look up. |
required |
actions_metadata
|
dict[str, ActionMetadata]
|
Metadata of the action space keyed by action name. |
required |
Returns:
| Type | Description |
|---|---|
tuple[str, str]
|
Tuple of (gripper_type, binary_gripper_range) values. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the key is missing from the action space or its metadata is not gripper metadata. |