mirror of
https://github.com/wassname/ray.git
synced 2026-07-11 14:42:06 +08:00
[RLlib] Issue 12483: Discrete observation space error: "ValueError: ('Observation ({}) outside given space ..." when doing Trainer.compute_action. (#12787)
This commit is contained in:
@@ -74,7 +74,7 @@ class WorkerSet:
|
||||
self.add_workers(num_workers)
|
||||
|
||||
# If num_workers > 0, get the action_spaces and observation_spaces
|
||||
# to not be forced to create an Env on the driver.
|
||||
# to not be forced to create an Env on the local worker.
|
||||
if self._remote_workers:
|
||||
remote_spaces = ray.get(self.remote_workers(
|
||||
)[0].foreach_policy.remote(
|
||||
@@ -263,13 +263,13 @@ class WorkerSet:
|
||||
elif config["input"] == "sampler":
|
||||
input_creator = (lambda ioctx: ioctx.default_sampler_input())
|
||||
elif isinstance(config["input"], dict):
|
||||
input_creator = (lambda ioctx: ShuffledInput(
|
||||
MixedInput(config["input"], ioctx), config[
|
||||
"shuffle_buffer_size"]))
|
||||
input_creator = (
|
||||
lambda ioctx: ShuffledInput(MixedInput(config["input"], ioctx),
|
||||
config["shuffle_buffer_size"]))
|
||||
else:
|
||||
input_creator = (lambda ioctx: ShuffledInput(
|
||||
JsonReader(config["input"], ioctx), config[
|
||||
"shuffle_buffer_size"]))
|
||||
input_creator = (
|
||||
lambda ioctx: ShuffledInput(JsonReader(config["input"], ioctx),
|
||||
config["shuffle_buffer_size"]))
|
||||
|
||||
if isinstance(config["output"], FunctionType):
|
||||
output_creator = config["output"]
|
||||
|
||||
@@ -80,9 +80,9 @@ class Preprocessor:
|
||||
obs_space = gym.spaces.Box(-1., 1., self.shape, dtype=np.float32)
|
||||
# Stash the unwrapped space so that we can unwrap dict and tuple spaces
|
||||
# automatically in model.py
|
||||
if (isinstance(self, TupleFlatteningPreprocessor)
|
||||
or isinstance(self, DictFlatteningPreprocessor)
|
||||
or isinstance(self, RepeatedValuesPreprocessor)):
|
||||
classes = (DictFlatteningPreprocessor, OneHotPreprocessor,
|
||||
RepeatedValuesPreprocessor, TupleFlatteningPreprocessor)
|
||||
if isinstance(self, classes):
|
||||
obs_space.original_space = self._obs_space
|
||||
return obs_space
|
||||
|
||||
|
||||
Reference in New Issue
Block a user