Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Why train_input_fn outputs 3 values #2

Closed
minhhoangbui opened this issue Jul 14, 2018 · 1 comment
Closed

Why train_input_fn outputs 3 values #2

minhhoangbui opened this issue Jul 14, 2018 · 1 comment

Comments

@minhhoangbui
Copy link

minhhoangbui commented Jul 14, 2018

In this function you outputs 3 values [x_train, x_len_train, y_train]:
def train_input_fn(): dataset = tf.data.Dataset.from_tensor_slices((x_train, x_len_train, y_train)) dataset = dataset.shuffle(buffer_size=len(x_train_variable)) dataset = dataset.batch(100) dataset = dataset.map(parser) dataset = dataset.repeat() iterator = dataset.make_one_shot_iterator() return iterator.get_next()

However, in Google document, they say:

The return value must be a two-element tuple organized as follows: :

The first element must be a dict in which each input feature is a key, and then a list of values for the training batch.

The second element is a list of labels for the training batch.

So I don't really understand that how custom Estimator can work with a tuple of 3 values
Thanks in advance

@eisenjulian
Copy link
Owner

The dataset API has functional-like interface for chaining operation on the input pipeline. In this case we are using the map method with the parser argument that takes the tuple of three arrays into the two-element structure that you describe

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants