conditional_action_unet
conditional_action_unet
¶
Conditional U-Net Decoder for action generation. Reference implementation: Diffusion Policy (https://arxiv.org/abs/2303.04137)
ConditionalActionUNet
¶
ConditionalActionUNet(input_keys, action_space, action_heads, observation_space, observation_horizon, prediction_horizon, device, embedding_dimension=256, down_dimensions=None, kernel_size=5, num_groups=8, condition_predict_scale=False)
Bases: ActionDecoder
Conditional U-Net decoder for generative action generation.
This architecture: - Uses FiLM (Feature-wise Linear Modulation) for conditioning - Accepts global conditioning from concatenated observation features - Optionally supports local (sequence-aligned) conditioning - Designed for use with Diffusion or Flow Matching algorithms
The decoder expects: - Noisy actions as input (via actions parameter during forward) - Timesteps injected by the algorithm (via features["timestep"]) - Observation features for global conditioning (via features dict)
Note: This decoder is specifically designed for diffusion/flow matching algorithms and expects the algorithm to handle noise scheduling and timestep injection.
Initialize Conditional U-Net decoder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_keys
|
list[str]
|
List of feature keys expected from encoder pipeline |
required |
action_space
|
ActionSpace
|
Action space configuration |
required |
action_heads
|
dict[str, ActionHead]
|
Must be empty. The U-Net owns its final convolution. |
required |
observation_space
|
ObservationSpace
|
Observation space configuration |
required |
observation_horizon
|
int
|
Number of observation timesteps (for history) |
required |
prediction_horizon
|
int
|
Number of actions to predict (horizon) |
required |
device
|
str
|
Device to run the model on |
required |
embedding_dimension
|
int
|
Diffusion timestep embedding dimension |
256
|
down_dimensions
|
list[int] | None
|
List of channel dimensions for downsampling layers |
None
|
kernel_size
|
int
|
Kernel size for convolutions in residual blocks |
5
|
num_groups
|
int
|
Number of groups for group normalization |
8
|
condition_predict_scale
|
bool
|
If True, conditions predict scaling factors in FiLM |
False
|
Source code in src/versatil/models/decoding/decoders/factory/conditional_action_unet.py
forward
¶
Forward pass through the conditional U-Net.
This method is called by the decoding algorithm (Diffusion, FlowMatching) which provides: - Noisy actions - Observation features dictionary containing the timestep key
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
features
|
dict[str, Tensor]
|
Dictionary of encoded features from the encoding pipeline. |
required |
actions
|
dict[str, Tensor] | None
|
Dictionary of noise-injected actions (provided by algorithm during training) |
None
|
Returns:
| Type | Description |
|---|---|
dict[str, Tensor]
|
Dictionary containing denoised predictions for each action head |
Raises:
| Type | Description |
|---|---|
ValueError
|
If timesteps or actions are missing. |