anhtld commited on
Commit
51d5706
·
verified ·
1 Parent(s): fd39c37

Add env_clip bounded CTT action transform

Browse files
workspace/scripts/eval_ctt_generated_rollout.py CHANGED
@@ -96,12 +96,14 @@ def main(argv: list[str] | None = None) -> int:
96
  )
97
  parser.add_argument(
98
  "--execution-action-transform",
99
- choices=("identity", "tanh"),
100
  default="identity",
101
  help=(
102
  "Action-convention transform applied before action-bound diagnostics, "
103
  "optional clipping, and simulator execution. 'identity' preserves "
104
- "decoded controls; 'tanh' smoothly maps controls into finite env bounds."
 
 
105
  ),
106
  )
107
  parser.add_argument(
@@ -1039,6 +1041,8 @@ def _transform_actions_4d(actions: np.ndarray, env: Any, transform: str) -> np.n
1039
  value = str(transform or "identity").strip().lower()
1040
  if value == "identity":
1041
  return actions.astype(np.float32, copy=False)
 
 
1042
  if value != "tanh":
1043
  raise ValueError(f"Unknown execution action transform: {transform}")
1044
  squashed = np.tanh(actions.astype(np.float32, copy=False))
 
96
  )
97
  parser.add_argument(
98
  "--execution-action-transform",
99
+ choices=("identity", "tanh", "env_clip"),
100
  default="identity",
101
  help=(
102
  "Action-convention transform applied before action-bound diagnostics, "
103
  "optional clipping, and simulator execution. 'identity' preserves "
104
+ "decoded controls; 'tanh' smoothly maps controls into finite env bounds; "
105
+ "'env_clip' clips decoded controls to the finite env bounds as an explicit "
106
+ "logged decoder convention rather than silent simulator clipping."
107
  ),
108
  )
109
  parser.add_argument(
 
1041
  value = str(transform or "identity").strip().lower()
1042
  if value == "identity":
1043
  return actions.astype(np.float32, copy=False)
1044
+ if value == "env_clip":
1045
+ return _clip_to_action_space_4d(actions.astype(np.float32, copy=False), env)
1046
  if value != "tanh":
1047
  raise ValueError(f"Unknown execution action transform: {transform}")
1048
  squashed = np.tanh(actions.astype(np.float32, copy=False))