conditional
conditional
¶
ConditionalEncoder
¶
ConditionalEncoder(input_specification, pretrained=False, frozen=False, device='cuda' if is_available() else 'cpu', model_dtype=None)
Bases: EncodingMixin
Encoder that conditions its outputs based on an external feature.
Subclasses implement encode(). The base class forward() handles
temporal flatten/unflatten — encode() receives tensors without a
time dimension.
Initialize conditional encoder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_specification
|
EncoderInput
|
Structured input specification with conditioning key. |
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/conditional.py
forward
¶
Forward pass with temporal flatten/unflatten.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
dict[str, Tensor]
|
Dict mapping input_keys to tensors with temporal dimension. |
required |
conditioning
|
Tensor
|
Conditioning tensor from another encoder. |
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/conditional.py
encode
abstractmethod
¶
Encode inputs with conditioning, without temporal dimension.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
dict[str, Tensor]
|
Dict mapping input_keys to tensors without temporal dimension. |
required |
conditioning
|
Tensor
|
Conditioning tensor (B, D). |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Tensor]
|
Dict mapping feature names to feature tensors. |