sample_builder
sample_builder
¶
Sample construction for episodic dataset.
Builds the final training/validation samples by: - Processing images - Adding proprioceptive data - Adding actions - Computing padding masks - Normalizing (and optionally tokenizing) observations and actions
SampleBuilder
¶
SampleBuilder(action_space, observation_space, obs_horizon, pred_horizon, action_backward_shift, image_processor, action_processor, tokenizer=None, normalizer=None)
Builds training samples from raw episode data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
action_space
|
ActionSpace
|
Action space of the experiment |
required |
observation_space
|
ObservationSpace
|
Observation space of the experiment |
required |
obs_horizon
|
int
|
Observation history length |
required |
pred_horizon
|
int
|
Action prediction horizon |
required |
action_backward_shift
|
int
|
Backward shift to give to action timesteps (if actions have latency) |
required |
image_processor
|
ImageProcessor
|
Handles augmentations |
required |
action_processor
|
ActionProcessor
|
Processes actions |
required |
tokenizer
|
Tokenizer | None
|
Unified tokenizer for observations and actions |
None
|
normalizer
|
LinearNormalizer | None
|
Normalizer for observations and actions |
None
|
Source code in src/versatil/data/sample_builder.py
build_sample
¶
Build a complete training sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
padded_data
|
dict[str, ndarray]
|
Dictionary of padded episode data |
required |
action_data
|
dict[str, ndarray]
|
Dictionary of computed actions |
required |
action_meta
|
dict[str, ActionMetadata]
|
Dictionary of action metadata |
required |
start_idx
|
int
|
Starting index in sampler |
required |
sampler_indices
|
ndarray
|
Array of sampler indices |
required |
Note
Padded data layout: [historical buffer | observation window | future] [0:k] [k:k+H] [k+H:end] where k=action_backward_shift, H=obs_horizon, end= prediction_horizon+k+H
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, Tensor]]
|
Dictionary containing observation and action dictionaries. Each sub-dictionary maps keys to tensors. |
Source code in src/versatil/data/sample_builder.py
normalize_and_tokenize_sample
¶
Normalize and tokenize a pre-built sample.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
sample
|
dict[str, dict[str, Tensor]]
|
Pre-built sample with observation and action dictionaries. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, dict[str, Tensor]]
|
Normalized and tokenized sample. |