60 lines
1.8 KiB
Python
60 lines
1.8 KiB
Python
from dataclasses import dataclass
|
|
from typing import List
|
|
|
|
from lerobot.common.optim.optimizers import AdamWConfig, OptimizerConfig
|
|
from lerobot.common.optim.schedulers import LRSchedulerConfig
|
|
from lerobot.configs.policies import PreTrainedConfig
|
|
|
|
|
|
@PreTrainedConfig.register_subclass(name="hilserl_classifier")
|
|
@dataclass
|
|
class ClassifierConfig(PreTrainedConfig):
|
|
"""Configuration for the Classifier model."""
|
|
|
|
name: str = "hilserl_classifier"
|
|
num_classes: int = 2
|
|
hidden_dim: int = 256
|
|
dropout_rate: float = 0.1
|
|
model_name: str = "helper2424/resnet10"
|
|
device: str = "cpu"
|
|
model_type: str = "cnn" # "transformer" or "cnn"
|
|
num_cameras: int = 2
|
|
learning_rate: float = 1e-4
|
|
weight_decay: float = 0.01
|
|
grad_clip_norm: float = 1.0
|
|
normalization_mapping: dict[str, NormalizationMode] = field(
|
|
default_factory=lambda: {
|
|
"VISUAL": NormalizationMode.MEAN_STD,
|
|
}
|
|
)
|
|
|
|
@property
|
|
def observation_delta_indices(self) -> List | None:
|
|
return None
|
|
|
|
@property
|
|
def action_delta_indices(self) -> List | None:
|
|
return None
|
|
|
|
@property
|
|
def reward_delta_indices(self) -> List | None:
|
|
return None
|
|
|
|
def get_optimizer_preset(self) -> OptimizerConfig:
|
|
return AdamWConfig(
|
|
lr=self.learning_rate,
|
|
weight_decay=self.weight_decay,
|
|
grad_clip_norm=self.grad_clip_norm,
|
|
)
|
|
|
|
def get_scheduler_preset(self) -> LRSchedulerConfig | None:
|
|
return None
|
|
|
|
def validate_features(self) -> None:
|
|
"""Validate feature configurations."""
|
|
has_image = any(key.startswith("observation.image") for key in self.input_features)
|
|
if not has_image:
|
|
raise ValueError(
|
|
"You must provide an image observation (key starting with 'observation.image') in the input features"
|
|
)
|