conditional_cnn
conditional_cnn
¶
FiLM-conditioned CNN encoder for conditioned vision encoding.
ConditionalCNNEncoder
¶
ConditionalCNNEncoder(input_keys, condition_key, conditioning_dimension, backbone=value, pooling_method=value, batch_norm_handling=value, pretrained=False, frozen=False, model_dtype=None, lora_config=None)
Bases: RGBEncoderMixin, ConditionalEncoder
CNN encoder with FiLM conditioning for conditioned vision, e.g. from language features.
Initialize FiLM-conditioned CNN encoder.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input_keys
|
str | list[str]
|
Camera observation keys. |
required |
condition_key
|
str
|
Key for the conditioning feature tensor. |
required |
conditioning_dimension
|
int
|
Dimensionality of the conditioning feature. |
required |
backbone
|
str
|
timm ResNet model name. |
value
|
pooling_method
|
str
|
Feature pooling strategy. |
value
|
batch_norm_handling
|
str
|
How to handle batch normalization layers. |
value
|
pretrained
|
bool
|
Whether to load pretrained weights. |
False
|
frozen
|
bool
|
Whether to freeze all parameters. |
False
|
model_dtype
|
str | None
|
Precision string from experiment config (e.g. |
None
|
lora_config
|
LoRAAdaptation | None
|
Optional PEFT LoRA adapter configuration. |
None
|
Source code in src/versatil/models/encoding/encoders/rgb/conditional_cnn.py
encode
¶
Encode images with FiLM conditioning.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
dict[str, Tensor]
|
Dict with camera images as (B, C, H, W) per camera key. |
required |
conditioning
|
Tensor
|
Conditioning tensor as (B, D). |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Tensor]
|
Dict with RGB features. Single camera: key is |
dict[str, Tensor]
|
Multiple cameras: keys are |
Source code in src/versatil/models/encoding/encoders/rgb/conditional_cnn.py
set_image_size
¶
Compute feature map dimensions and create pooling head.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
image_height
|
int
|
Target image height. |
required |
image_width
|
int
|
Target image width. |
required |
Source code in src/versatil/models/encoding/encoders/rgb/conditional_cnn.py
validate_input_metadata
¶
Validate that input metadata is camera metadata.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
Observation key being validated. |
required |
metadata
|
BaseMetadata
|
Metadata from the observation space. |
required |
Returns:
| Type | Description |
|---|---|
str | None
|
Error message if incompatible, None if valid. |
Source code in src/versatil/models/encoding/encoders/rgb/conditional_cnn.py
get_explainability_targets
¶
Return the last FiLM residual block for spatial attribution maps.
Returns:
| Type | Description |
|---|---|
list[VisionExplanationTarget]
|
One NCHW spatial feature-map target pointing at the final block of |
list[VisionExplanationTarget]
|
|
Source code in src/versatil/models/encoding/encoders/rgb/conditional_cnn.py
get_output_specification
¶
Get structured output specification with feature names and dimensions.
Returns:
| Type | Description |
|---|---|
list[FeatureMetadata]
|
List of FeatureMetadata with per-camera feature names and pooled dimensions. |