Fix Tensorflow direct V2.1 multiple FileWriters

This commit is contained in:
allegroai 2020-03-22 18:17:16 +02:00
parent 493cce443a
commit 332e9e2f63

View File

@ -1006,9 +1006,18 @@ class PatchTensorFlowEager(object):
try:
from tensorflow.python.eager import context
logdir = context.context().summary_writer._init_op_fn.keywords.get('logdir')
logdir = logdir.numpy().decode()
except:
try:
from tensorflow.python.ops.summary_ops_v2 import _summary_state
logdir = _summary_state.writer._init_op_fn.keywords.get('logdir')
except:
logdir = None
try:
if logdir is not None:
logdir = logdir.numpy().decode()
except:
logdir = None
PatchTensorFlowEager.__trains_event_writer[id(writer)] = EventTrainsWriter(
logger=PatchTensorFlowEager.__main_task.get_logger(), logdir=logdir,
**PatchTensorFlowEager.defaults_dict)