Fix writing binary summaries in python3.

In python 3, tf.string tensors are bytes() objects when fetched, not str(). six.binary_type
maps exactly to tf.string in python 2 and 3, so use it to determine if we should try to interpret
a metric as a tf.Summary proto.
This commit is contained in:
Boris Pfahringer 2018-01-29 15:51:15 +00:00 committed by Boris Pfahringer
parent 92d622d27f
commit 0b012956d2

View File

@ -1103,7 +1103,7 @@ def _write_dict_to_summary(output_dir,
isinstance(dictionary[key], np.int32) or
isinstance(dictionary[key], int)):
summary_proto.value.add(tag=key, simple_value=int(dictionary[key]))
elif isinstance(dictionary[key], six.string_types):
elif isinstance(dictionary[key], six.binary_type):
try:
summ = summary_pb2.Summary.FromString(dictionary[key])
for i, _ in enumerate(summ.value):