Commit 14b8bf25 authored by Christopher Shallue's avatar Christopher Shallue
Browse files

Add explicit bytes encoding for Python3 compatibility.

parent a6091ec4
......@@ -140,7 +140,8 @@ def _set_float_feature(ex, name, value):
def _set_bytes_feature(ex, name, value):
"""Sets the value of a bytes feature in a tensorflow.train.Example proto."""
assert name not in ex.features.feature, "Duplicate feature: %s" % name
ex.features.feature[name].bytes_list.value.extend([str(v) for v in value])
ex.features.feature[name].bytes_list.value.extend([
str(v).encode("latin-1") for v in value])
def _set_int64_feature(ex, name, value):
......@@ -187,7 +188,7 @@ def _process_tce(tce):
try:
_set_float_feature(ex, col_name, [float(value)])
except ValueError:
_set_bytes_feature(ex, col_name, [str(value)])
_set_bytes_feature(ex, col_name, [value])
return ex
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment