behavior_cloning
behavior_cloning
¶
Behavioral Cloning (BC) algorithm for supervised action prediction.
For multi-modal action prediction with latent variables, use:
VariationalAlgorithm(BehavioralCloning(), VAETransformerEncoder(...))
This provides the same functionality as the old BehavioralCloning with latent_encoder, but with a cleaner compositional design.
BehavioralCloning
¶
Bases: DecodingAlgorithm
Pure Behavioral Cloning algorithm without variational inference.
Simplest imitation learning approach: directly predicts actions from observations using supervised learning. The network is trained to minimize the difference between predicted and ground-truth actions.
This is a deterministic, uni-modal algorithm. For multi-modal action prediction, wrap with VariationalAlgorithm: VariationalAlgorithm(BehavioralCloning(), VAETransformerEncoder(...))
Initialize Behavioral Cloning algorithm.
Source code in src/versatil/models/decoding/algorithm/behavior_cloning.py
forward
¶
Forward pass during training.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
network
|
ActionDecoder
|
The action decoder network module |
required |
features
|
dict[str, Tensor]
|
Dictionary of encoded features from the encoding pipeline. |
required |
actions
|
dict[str, Tensor] | None
|
Optional dictionary of ground truth actions, if architecture requires it (e.g., DETR). |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Tensor]
|
Decoder output dictionary containing action predictions and any architecture-specific outputs. |
dict[str, Tensor]
|
Keys typically include: - 'position_action': Predicted position actions (B, T, D_pos) - 'orientation_action': Predicted orientation actions if used (B, T, D_ori) - 'gripper_action': Predicted gripper actions if used (B, T, D_grip) - Additional architecture-specific outputs (e.g., 'is_pad') |
Source code in src/versatil/models/decoding/algorithm/behavior_cloning.py
predict
¶
Inference/prediction pass.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
network
|
ActionDecoder
|
The action decoder network module |
required |
features
|
dict[str, Tensor]
|
Dict of encoded features from encoding pipeline |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Tensor]
|
Decoder output dictionary containing action predictions. |
dict[str, Tensor]
|
Keys typically include: - 'position_action': Predicted position actions (B, T, D_pos) - 'orientation_action': Predicted orientation actions if used (B, T, D_ori) - 'gripper_action': Predicted gripper actions if used (B, T, D_grip) |