fix: explicit arms length check
This commit is contained in:
parent
6ed4ad8060
commit
143dbbc710
4 changed files with 18 additions and 3 deletions
|
|
@ -4,6 +4,7 @@
|
||||||
# Default values are defined in CentralizedConfig dataclass.
|
# Default values are defined in CentralizedConfig dataclass.
|
||||||
# Use this configuration for standard PPO experiments.
|
# Use this configuration for standard PPO experiments.
|
||||||
|
|
||||||
|
name: "centralized"
|
||||||
sensor:
|
sensor:
|
||||||
hidden_dims: [64, 64]
|
hidden_dims: [64, 64]
|
||||||
activation: "tanh"
|
activation: "tanh"
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@
|
||||||
# Default values are defined in DecentralizedConfig dataclass.
|
# Default values are defined in DecentralizedConfig dataclass.
|
||||||
# Use this configuration for decentralized execution experiments.
|
# Use this configuration for decentralized execution experiments.
|
||||||
|
|
||||||
|
name: "decentralized"
|
||||||
sensor:
|
sensor:
|
||||||
hidden_dims: [64, 64]
|
hidden_dims: [64, 64]
|
||||||
activation: "tanh"
|
activation: "tanh"
|
||||||
|
|
|
||||||
|
|
@ -42,10 +42,22 @@ def compute_padding_masks(
|
||||||
Returns:
|
Returns:
|
||||||
A dict containing 1D boolean masks and target sizes.
|
A dict containing 1D boolean masks and target sizes.
|
||||||
"""
|
"""
|
||||||
|
if len(segments_per_arm) != len(reference_segments_per_arm):
|
||||||
|
raise ValueError(
|
||||||
|
f"Morphology mismatch: current has {len(segments_per_arm)} arms, "
|
||||||
|
f"but reference requires {len(reference_segments_per_arm)} arms."
|
||||||
|
)
|
||||||
|
|
||||||
mask_1x = []
|
mask_1x = []
|
||||||
mask_2x = []
|
mask_2x = []
|
||||||
|
|
||||||
for actual, ref in zip(segments_per_arm, reference_segments_per_arm):
|
for arm_idx, (actual, ref) in enumerate(zip(segments_per_arm, reference_segments_per_arm)):
|
||||||
|
if not (0 <= actual <= ref):
|
||||||
|
raise ValueError(
|
||||||
|
f"Invalid amputation at arm {arm_idx}: "
|
||||||
|
f"actual segments ({actual}) must be between 0 and reference ({ref})."
|
||||||
|
)
|
||||||
|
# 1x scaling (e.g., contacts: 1 value per segment)
|
||||||
# 1x scaling (e.g., contacts: 1 value per segment)
|
# 1x scaling (e.g., contacts: 1 value per segment)
|
||||||
mask_1x.extend([True] * actual + [False] * (ref - actual))
|
mask_1x.extend([True] * actual + [False] * (ref - actual))
|
||||||
# 2x scaling (e.g., joints: 2 values per segment)
|
# 2x scaling (e.g., joints: 2 values per segment)
|
||||||
|
|
|
||||||
|
|
@ -18,7 +18,8 @@ def test_config_composition_centralized():
|
||||||
structured_cfg = OmegaConf.to_object(OmegaConf.merge(BrittleStarConfig, cfg))
|
structured_cfg = OmegaConf.to_object(OmegaConf.merge(BrittleStarConfig, cfg))
|
||||||
|
|
||||||
# Basic assertions
|
# Basic assertions
|
||||||
assert "CentralizedConfig" in str(type(structured_cfg.architecture))
|
assert structured_cfg.architecture.name == "centralized"
|
||||||
|
assert structured_cfg.architecture.propagator is None
|
||||||
assert isinstance(structured_cfg.ppo.learning_rate, float)
|
assert isinstance(structured_cfg.ppo.learning_rate, float)
|
||||||
assert structured_cfg.ppo.learning_rate > 0
|
assert structured_cfg.ppo.learning_rate > 0
|
||||||
|
|
||||||
|
|
@ -32,7 +33,7 @@ def test_config_composition_decentralized():
|
||||||
structured_cfg = OmegaConf.to_object(OmegaConf.merge(BrittleStarConfig, cfg))
|
structured_cfg = OmegaConf.to_object(OmegaConf.merge(BrittleStarConfig, cfg))
|
||||||
|
|
||||||
# Basic assertions
|
# Basic assertions
|
||||||
assert "DecentralizedConfig" in str(type(structured_cfg.architecture))
|
assert structured_cfg.architecture.name == "decentralized"
|
||||||
assert isinstance(structured_cfg.ppo.learning_rate, float)
|
assert isinstance(structured_cfg.ppo.learning_rate, float)
|
||||||
assert structured_cfg.ppo.learning_rate > 0
|
assert structured_cfg.ppo.learning_rate > 0
|
||||||
|
|
||||||
|
|
|
||||||
Reference in a new issue