Revert feat(normalization): add validation for empty features in NormalizerProcessorStep and UnnormalizerProcessorStep (#2087)
Revert "feat(normalization): add validation for empty features in NormalizerProcessorStep and UnnormalizerProcessorStep (#2087)"
This reverts commit f173265354.
This commit is contained in:
@@ -108,18 +108,16 @@ class _NormalizationMixin:
|
||||
"""
|
||||
# Track if stats were explicitly provided (not None and not empty)
|
||||
self._stats_explicitly_provided = self.stats is not None and bool(self.stats)
|
||||
# Check if self.features is not empty
|
||||
if not self.features:
|
||||
raise ValueError("Normalization features cannot be empty")
|
||||
# Robust JSON deserialization handling (guard empty maps).
|
||||
first_val = next(iter(self.features.values()))
|
||||
if isinstance(first_val, dict):
|
||||
reconstructed = {}
|
||||
for key, ft_dict in self.features.items():
|
||||
reconstructed[key] = PolicyFeature(
|
||||
type=FeatureType(ft_dict["type"]), shape=tuple(ft_dict["shape"])
|
||||
)
|
||||
self.features = reconstructed
|
||||
if self.features:
|
||||
first_val = next(iter(self.features.values()))
|
||||
if isinstance(first_val, dict):
|
||||
reconstructed = {}
|
||||
for key, ft_dict in self.features.items():
|
||||
reconstructed[key] = PolicyFeature(
|
||||
type=FeatureType(ft_dict["type"]), shape=tuple(ft_dict["shape"])
|
||||
)
|
||||
self.features = reconstructed
|
||||
|
||||
# if keys are strings (JSON), rebuild enum map
|
||||
if self.norm_map and all(isinstance(k, str) for k in self.norm_map):
|
||||
|
||||
@@ -234,6 +234,7 @@ def test_act_backbone_lr():
|
||||
assert cfg.policy.optimizer_lr_backbone == 0.001
|
||||
|
||||
dataset = make_dataset(cfg)
|
||||
preprocessor, _ = make_pre_post_processors(cfg.policy, None)
|
||||
policy = make_policy(cfg.policy, ds_meta=dataset.meta)
|
||||
optimizer, _ = make_optimizer_and_scheduler(cfg, policy)
|
||||
assert len(optimizer.param_groups) == 2
|
||||
|
||||
@@ -534,18 +534,6 @@ def test_empty_observation():
|
||||
assert result == transition
|
||||
|
||||
|
||||
def test_empty_features_raises_error():
|
||||
"""Test that empty features dict raises ValueError."""
|
||||
norm_map = {FeatureType.VISUAL: NormalizationMode.MEAN_STD}
|
||||
stats = {OBS_IMAGE: {"mean": [0.5], "std": [0.2]}}
|
||||
|
||||
with pytest.raises(ValueError, match="Normalization features cannot be empty"):
|
||||
NormalizerProcessorStep(features={}, norm_map=norm_map, stats=stats)
|
||||
|
||||
with pytest.raises(ValueError, match="Normalization features cannot be empty"):
|
||||
UnnormalizerProcessorStep(features={}, norm_map=norm_map, stats=stats)
|
||||
|
||||
|
||||
def test_empty_stats():
|
||||
features = {OBS_IMAGE: PolicyFeature(FeatureType.VISUAL, (3, 96, 96))}
|
||||
norm_map = {FeatureType.VISUAL: NormalizationMode.MEAN_STD}
|
||||
|
||||
Reference in New Issue
Block a user