mirror of
https://github.com/wassname/ray.git
synced 2026-07-07 05:35:39 +08:00
Added python2 support and check for outdated tf (#562)
Improve the Evolutionary Strategies example.
This commit is contained in:
committed by
Robert Nishihara
parent
28f0882387
commit
f861124b9a
@@ -76,7 +76,7 @@ class Policy:
|
||||
|
||||
# === Rollouts/training ===
|
||||
|
||||
def rollout(self, env, *, render=False, timestep_limit=None, save_obs=False,
|
||||
def rollout(self, env, render=False, timestep_limit=None, save_obs=False,
|
||||
random_stream=None):
|
||||
"""Do a rollout.
|
||||
|
||||
|
||||
@@ -79,12 +79,13 @@ def dump_tabular():
|
||||
_Logger.CURRENT.dump_tabular()
|
||||
|
||||
|
||||
def log(*args, level=INFO):
|
||||
def log(*args, **kwargs):
|
||||
"""Write the sequence of args, with no separators.
|
||||
|
||||
This is written to the console and output files (if you've configured an
|
||||
output file).
|
||||
"""
|
||||
level = kwargs['level'] if 'level' in kwargs else INFO
|
||||
_Logger.CURRENT.log(*args, level=level)
|
||||
|
||||
|
||||
@@ -177,7 +178,8 @@ class _Logger(object):
|
||||
self.tbwriter.write_values(self.name2val)
|
||||
self.name2val.clear()
|
||||
|
||||
def log(self, *args, level=INFO):
|
||||
def log(self, *args, **kwargs):
|
||||
level = kwargs['level'] if 'level' in kwargs else INFO
|
||||
if self.level <= level:
|
||||
self._do_log(*args)
|
||||
|
||||
@@ -198,7 +200,7 @@ class _Logger(object):
|
||||
# Misc
|
||||
|
||||
def _do_log(self, *args):
|
||||
self._write_text(*args, '\n')
|
||||
self._write_text(*args + ('\n',))
|
||||
for f in self.text_outputs:
|
||||
try:
|
||||
f.flush()
|
||||
|
||||
@@ -10,6 +10,11 @@ import tensorflow as tf
|
||||
import functools
|
||||
import os
|
||||
|
||||
# Tensorflow must be at least version 1.0.0 for the example to work.
|
||||
if int(tf.__version__.split(".")[0]) < 1:
|
||||
raise Exception("Your Tensorflow version is less than 1.0.0. Please update "
|
||||
"Tensorflow to the latest version.")
|
||||
|
||||
# ================================================================
|
||||
# Import all names into common namespace
|
||||
# ================================================================
|
||||
|
||||
Reference in New Issue
Block a user