[rllib] Support discrete observation spaces such as FrozenLake-v0 (#1140)

* add

* remove transform_shape

* fix test

* fix
This commit is contained in:
Eric Liang
2017-10-23 23:16:52 -07:00
committed by Richard Liaw
parent 0c9817fa76
commit cd9dc398ff
10 changed files with 98 additions and 66 deletions
+4 -10
View File
@@ -74,10 +74,7 @@ class Worker(object):
self.noise = SharedNoiseTable(noise)
self.env = env_creator()
self.preprocessor = ModelCatalog.get_preprocessor(
self.env.spec.id, self.env.observation_space.shape)
self.preprocessor_shape = self.preprocessor.transform_shape(
self.env.observation_space.shape)
self.preprocessor = ModelCatalog.get_preprocessor(self.env)
self.sess = utils.make_session(single_threaded=True)
self.policy = policies.GenericPolicy(
@@ -118,7 +115,7 @@ class Worker(object):
noise_inds, returns, sign_returns, lengths = [], [], [], []
# We set eps=0 because we're incrementing only.
task_ob_stat = utils.RunningStat(self.preprocessor_shape, eps=0)
task_ob_stat = utils.RunningStat(self.preprocessor.shape, eps=0)
# Perform some rollouts with noise.
task_tstart = time.time()
@@ -169,10 +166,7 @@ class ESAgent(Agent):
}
env = self.env_creator()
preprocessor = ModelCatalog.get_preprocessor(
env.spec.id, env.observation_space.shape)
preprocessor_shape = preprocessor.transform_shape(
env.observation_space.shape)
preprocessor = ModelCatalog.get_preprocessor(env)
self.sess = utils.make_session(single_threaded=False)
self.policy = policies.GenericPolicy(
@@ -180,7 +174,7 @@ class ESAgent(Agent):
**policy_params)
tf_util.initialize()
self.optimizer = optimizers.Adam(self.policy, self.config["stepsize"])
self.ob_stat = utils.RunningStat(preprocessor_shape, eps=1e-2)
self.ob_stat = utils.RunningStat(preprocessor.shape, eps=1e-2)
# Create the shared noise table.
print("Creating shared noise table.")