Added python2 support and check for outdated tf (#562)

Improve the Evolutionary Strategies example.
This commit is contained in:
Wapaul1
2017-05-17 20:42:17 -07:00
committed by Robert Nishihara
parent 28f0882387
commit f861124b9a
3 changed files with 11 additions and 4 deletions
+1 -1
View File
@@ -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()
+5
View File
@@ -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
# ================================================================