[rllib] Better error message when action space dim too high (#3119)

This commit is contained in:
Eric Liang
2018-10-26 16:55:00 -07:00
committed by Richard Liaw
parent 658c14282c
commit 6531eed2d0
2 changed files with 10 additions and 0 deletions
@@ -432,6 +432,8 @@ class PolicyEvaluator(EvaluatorInterface):
info_out = {k: builder.get(v) for k, v in info_out.items()}
else:
for pid, batch in samples.policy_batches.items():
if pid not in self.policies_to_train:
continue
grad_out[pid], info_out[pid] = (
self.policy_map[pid].compute_gradients(batch))
else:
@@ -472,6 +474,8 @@ class PolicyEvaluator(EvaluatorInterface):
info_out = {k: builder.get(v) for k, v in info_out.items()}
else:
for pid, batch in samples.policy_batches.items():
if pid not in self.policies_to_train:
continue
info_out[pid], _ = (
self.policy_map[pid].compute_apply(batch))
return info_out
+6
View File
@@ -105,6 +105,12 @@ class ModelCatalog(object):
config = config or MODEL_DEFAULTS
if isinstance(action_space, gym.spaces.Box):
if len(action_space.shape) > 1:
raise ValueError(
"Action space has multiple dimensions "
"{}. ".format(action_space.shape) +
"Consider reshaping this into a single dimension, "
"using a Tuple action space, or the multi-agent API.")
if dist_type is None:
dist = DiagGaussian
if config.get("squash_to_range"):