mirror of
https://github.com/wassname/ray.git
synced 2026-09-10 12:38:43 +08:00
[sgd/tune][minor] more tf ports (#5953)
This commit is contained in:
@@ -148,6 +148,11 @@ def tf2_compat_logger(config, logdir, trial=None):
|
||||
use_tf2_api = (distutils.version.LooseVersion(tf.__version__) >=
|
||||
distutils.version.LooseVersion("1.15.0"))
|
||||
if use_tf2_api:
|
||||
# This is temporarily for RLlib because it disables v2 behavior...
|
||||
from tensorflow.python import tf2
|
||||
if not tf2.enabled():
|
||||
tf = tf.compat.v1
|
||||
return TFLogger(config, logdir, trial)
|
||||
tf = tf.compat.v2 # setting this for TF2.0
|
||||
return TF2Logger(config, logdir, trial)
|
||||
else:
|
||||
@@ -166,6 +171,10 @@ class TF2Logger(Logger):
|
||||
"""
|
||||
|
||||
def _init(self):
|
||||
global tf
|
||||
if tf is None:
|
||||
import tensorflow as tf
|
||||
tf = tf.compat.v2 # setting this for TF2.0
|
||||
self._file_writer = None
|
||||
self._hp_logged = False
|
||||
|
||||
@@ -237,6 +246,10 @@ class TFLogger(Logger):
|
||||
"""
|
||||
|
||||
def _init(self):
|
||||
global tf
|
||||
if tf is None:
|
||||
import tensorflow as tf
|
||||
tf = tf.compat.v1 # setting this for regular TF logger
|
||||
logger.debug("Initializing TFLogger instead of TF2Logger.")
|
||||
self._file_writer = tf.summary.FileWriter(self.logdir)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user