[RLlib] Issue 12483: Discrete observation space error: "ValueError: ('Observation ({}) outside given space ..." when doing Trainer.compute_action. (#12787)

This commit is contained in:
Sven Mika
2020-12-11 22:43:30 +01:00
committed by GitHub
parent 676ec363f6
commit abb1eefdc2
2 changed files with 10 additions and 10 deletions
+7 -7
View File
@@ -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"]
+3 -3
View File
@@ -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