mirror of
https://github.com/wassname/ray.git
synced 2026-09-09 11:32:43 +08:00
Policy gradient example: record stats for tensorboard (#577)
* add tf metrics * comments * fix network scopes * add doc * use format string * fix trace level * plot intermediate and final sgd stats * add back a global step
This commit is contained in:
committed by
Philipp Moritz
parent
c440010cbd
commit
06241daf61
@@ -21,15 +21,18 @@ class Agent(object):
|
||||
if preprocessor.shape is None:
|
||||
preprocessor.shape = self.env.observation_space.shape
|
||||
self.sess = tf.Session()
|
||||
self.ppo = ProximalPolicyLoss(self.env.observation_space,
|
||||
self.env.action_space, preprocessor, config,
|
||||
self.sess)
|
||||
self.optimizer = tf.train.AdamOptimizer(config["sgd_stepsize"])
|
||||
self.train_op = self.optimizer.minimize(self.ppo.loss)
|
||||
self.variables = ray.experimental.TensorFlowVariables(self.ppo.loss,
|
||||
self.sess)
|
||||
self.observation_filter = MeanStdFilter(preprocessor.shape, clip=None)
|
||||
self.reward_filter = MeanStdFilter((), clip=5.0)
|
||||
with tf.name_scope("policy_gradient/train"):
|
||||
with tf.name_scope("proximal_policy_loss"):
|
||||
self.ppo = ProximalPolicyLoss(self.env.observation_space,
|
||||
self.env.action_space, preprocessor,
|
||||
config, self.sess)
|
||||
with tf.name_scope("adam_optimizer"):
|
||||
self.optimizer = tf.train.AdamOptimizer(config["sgd_stepsize"])
|
||||
self.train_op = self.optimizer.minimize(self.ppo.loss)
|
||||
self.variables = ray.experimental.TensorFlowVariables(self.ppo.loss,
|
||||
self.sess)
|
||||
self.observation_filter = MeanStdFilter(preprocessor.shape, clip=None)
|
||||
self.reward_filter = MeanStdFilter((), clip=5.0)
|
||||
self.sess.run(tf.global_variables_initializer())
|
||||
|
||||
def get_weights(self):
|
||||
|
||||
Reference in New Issue
Block a user