Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
ModelZoo
ResNet50_tensorflow
Commits
14b8bf25
Commit
14b8bf25
authored
Mar 15, 2018
by
Christopher Shallue
Browse files
Add explicit bytes encoding for Python3 compatibility.
parent
a6091ec4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
research/astronet/astronet/data/generate_input_records.py
research/astronet/astronet/data/generate_input_records.py
+3
-2
No files found.
research/astronet/astronet/data/generate_input_records.py
View file @
14b8bf25
...
@@ -140,7 +140,8 @@ def _set_float_feature(ex, name, value):
...
@@ -140,7 +140,8 @@ def _set_float_feature(ex, name, value):
def
_set_bytes_feature
(
ex
,
name
,
value
):
def
_set_bytes_feature
(
ex
,
name
,
value
):
"""Sets the value of a bytes feature in a tensorflow.train.Example proto."""
"""Sets the value of a bytes feature in a tensorflow.train.Example proto."""
assert
name
not
in
ex
.
features
.
feature
,
"Duplicate feature: %s"
%
name
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
):
def
_set_int64_feature
(
ex
,
name
,
value
):
...
@@ -187,7 +188,7 @@ def _process_tce(tce):
...
@@ -187,7 +188,7 @@ def _process_tce(tce):
try
:
try
:
_set_float_feature
(
ex
,
col_name
,
[
float
(
value
)])
_set_float_feature
(
ex
,
col_name
,
[
float
(
value
)])
except
ValueError
:
except
ValueError
:
_set_bytes_feature
(
ex
,
col_name
,
[
str
(
value
)
])
_set_bytes_feature
(
ex
,
col_name
,
[
value
])
return
ex
return
ex
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment