unconditional
unconditional
¶
Encoder
¶
Encoder(input_specification, pretrained=False, frozen=False, device='cuda' if is_available() else 'cpu', model_dtype=None)
Bases: EncodingMixin
Base class for all unconditional encoders.
Subclasses implement encode(). The base class
forward() handles temporal flatten/unflatten — encode() receives
tensors with the temporal axis flattened into the batch (images as
(B*T, C, H, W), not (B, T, C, H, W)).
Initialize base encoder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_specification
|
EncoderInput
|
Structured input specification for this encoder |
required |
pretrained
|
bool
|
Whether to use pretrained weights |
False
|
frozen
|
bool
|
Whether to freeze encoder weights |
False
|
device
|
str | None
|
Device to place the encoder on |
'cuda' if is_available() else 'cpu'
|
model_dtype
|
str | None
|
Precision string from experiment config (e.g. |
None
|
Source code in src/versatil/models/encoding/encoders/unconditional.py
forward
¶
Forward pass with temporal flatten/unflatten.
All input tensors must have a temporal dimension: images as (B, T, C, H, W), sequences as (B, T, S), vectors as (B, T, D). The temporal dimension is flattened into batch before calling encode(), then restored after.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
dict[str, Tensor]
|
Dict mapping input_keys to tensors with temporal dimension. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Tensor]
|
Dict mapping feature names to feature tensors with temporal dimension. |
Source code in src/versatil/models/encoding/encoders/unconditional.py
encode
abstractmethod
¶
Encode temporally flattened inputs.
Subclasses implement this. Images are (BT, C, H, W),
tokenized text is (BT, S), proprioceptive state is (B*T, D);
forward() flattens the temporal axis into the batch before
dispatching here.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
dict[str, Tensor]
|
Dict mapping input_keys to temporally flattened tensors. |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Tensor]
|
Dict mapping feature names to feature tensors. |