Skip to content
This repository has been archived by the owner on Jul 7, 2023. It is now read-only.

Commit

Permalink
Fixing feature encoder for tf.string variable length features.
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 314208560
  • Loading branch information
eli7 authored and copybara-github committed Jun 1, 2020
1 parent c104976 commit 2c48f89
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions tensor2tensor/data_generators/problem.py
Original file line number Diff line number Diff line change
Expand Up @@ -718,10 +718,14 @@ def decode_example(self, serialized_example):
[1], tf.int64, getattr(self._hparams, "sampling_keep_top_k", -1))

if data_items_to_decoders is None:
data_items_to_decoders = {
field: contrib.slim().tfexample_decoder.Tensor(field)
for field in data_fields
}
data_items_to_decoders = {}
for field in data_fields:
if data_fields[field].dtype is tf.string:
default_value = b""
else:
default_value = 0
data_items_to_decoders[field] = contrib.slim().tfexample_decoder.Tensor(
field, default_value=default_value)

decoder = contrib.slim().tfexample_decoder.TFExampleDecoder(
data_fields, data_items_to_decoders)
Expand Down

0 comments on commit 2c48f89

Please sign in to comment.