Weird behaviour in observation space

How severe does this issue affect your experience of using Ray?

  • High: It blocks me to complete my task.

Why does

get_obs_space stops working when I set
‘idx’: gym.spaces.Discrete(3),
‘var’: gym.spaces.Box(low=-np.inf, high=np.inf, shape=(3,1)),

but it was fine 2 seconds back when that line was
‘var’: gym.spaces.Box(low=0.0, high=1.0, shape=(3,1)),

Isn’t -np.inf to np.inf more inclusive than 0.0 to 1.0? I don’t understand this at all, please help.

Hi @hridayns,

Can you post the full error with stack trace?

I personally never use inf. I use the min and max of the data type used by the space.

Failure # 1 (occurred at 2022-08-30_03-50-20)
Traceback (most recent call last):
  File "/usr/local/lib/python3.6/dist-packages/ray/tune/", line 886, in _process_trial
    results = self.trial_executor.fetch_result(trial)
  File "/usr/local/lib/python3.6/dist-packages/ray/tune/", line 675, in fetch_result
    result = ray.get(trial_future[0], timeout=DEFAULT_GET_TIMEOUT)
  File "/usr/local/lib/python3.6/dist-packages/ray/_private/", line 105, in wrapper
    return func(*args, **kwargs)
  File "/usr/local/lib/python3.6/dist-packages/ray/", line 1765, in get
    raise value
ray.exceptions.RayActorError: The actor died because of an error raised in its creation task, e[36mray::PPOTrainer.__init__()e[39m (pid=166, ip=, repr=PPOTrainer)
  File "/usr/local/lib/python3.6/dist-packages/ray/rllib/agents/", line 925, in _init
    raise NotImplementedError

During handling of the above exception, another exception occurred:

e[36mray::PPOTrainer.__init__()e[39m (pid=166, ip=, repr=PPOTrainer)
  File "/usr/local/lib/python3.6/dist-packages/ray/rllib/agents/", line 747, in __init__
  File "/usr/local/lib/python3.6/dist-packages/ray/tune/", line 124, in __init__
  File "/usr/local/lib/python3.6/dist-packages/ray/rllib/agents/", line 827, in setup
  File "/usr/local/lib/python3.6/dist-packages/ray/rllib/agents/", line 2002, in _make_workers
  File "/usr/local/lib/python3.6/dist-packages/ray/rllib/evaluation/", line 103, in __init__
    lambda p, pid: (pid, p.observation_space, p.action_space)))
ray.exceptions.RayActorError: The actor died because of an error raised in its creation task, e[36mray::RolloutWorker.__init__()e[39m (pid=164, ip=, repr=<ray.rllib.evaluation.rollout_worker.RolloutWorker object at 0x7f0b11b84cf8>)
  File "/usr/local/lib/python3.6/dist-packages/ray/rllib/evaluation/", line 590, in __init__
  File "/usr/local/lib/python3.6/dist-packages/ray/rllib/evaluation/", line 1578, in _build_policy_map
    conf, merged_conf)
  File "/usr/local/lib/python3.6/dist-packages/ray/rllib/policy/", line 134, in create_policy
    observation_space, action_space, merged_config)
  File "/usr/local/lib/python3.6/dist-packages/ray/rllib/policy/", line 252, in __init__
  File "/usr/local/lib/python3.6/dist-packages/ray/rllib/policy/", line 334, in __init__
  File "/usr/local/lib/python3.6/dist-packages/ray/rllib/models/", line 232, in __call__
    input_dict["obs"], self.obs_space, self.framework)
  File "/usr/local/lib/python3.6/dist-packages/ray/rllib/models/", line 394, in restore_original_dimensions
    return _unpack_obs(obs, original_space, tensorlib=tensorlib)
  File "/usr/local/lib/python3.6/dist-packages/ray/rllib/models/", line 430, in _unpack_obs
    prep.shape[0], obs.shape))
ValueError: Expected flattened obs shape of [..., 10], got (?, 6)

Also when I tried to upgrade to Ray 2.0.0 from Ray 1.11, there are multiple other errors popping up and decided to go back to the safety of Ray 1.11. Any guide to upgrade from previous versions of Ray to Ray 2.0.0 - or should i make a new post about this?


I had made some changes to my observations as well, and that seems to have an effect on the shape even though i previously thought it was the same shape.

Hi @hridayns,

That makes more sense. I too was baffled by how changing the bounds of the values would lead to a shape error.

As for upgrading, perhaps someone else has more information I just worked through each issue one at a time when. I upgraded.