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

input_fn called multiple times in Estimator.train #143

Open
shendiaomo opened this issue Jan 13, 2020 · 5 comments
Open

input_fn called multiple times in Estimator.train #143

shendiaomo opened this issue Jan 13, 2020 · 5 comments

Comments

@shendiaomo
Copy link

result = temp_estimator.train(
input_fn=input_fn,
hooks=hooks,
max_steps=max_steps,
saving_listeners=saving_listeners)

It seems to be problematic because adanet.Estimator.train would load data from scratch at every iteration.
As tensorflow/tensorflow#19062 (comment) said, in canned TF estimators train is called once.

@shendiaomo
Copy link
Author

There seem to be two negative effects of this:

  1. A repeated Dataset (dataset.repeat(10) for example) cannot stop training via OutOfRangeError or StopIteration, we have to set steps or max_steps, which is inconsistent with canned Estimators.
  2. If a user doesn't shuffle the dataset, AdaNet may repeatedly use the first max_iteration_steps * batch_size samples each time, thus fitting to a subset of the training data.

Am I right? @cweill

@cweill
Copy link
Contributor

cweill commented Jan 14, 2020

@shendiaomo: You are correct on both counts. For this reason, we request that the user configures the max_iteration_steps to be the number of repetitions desired, which unfortunately requires the user to do some extra math (max_iteration_steps = num_examples / batch_size * num_epochs_per_iteration).

Assuming each adanet iteration trains over several epochs, 2. should be less of an issue in practice if your base learners are randomly initialized. They will tend to learn different biases, and form a strong ensemble regardless.

@shendiaomo
Copy link
Author

@shendiaomo: You are correct on both counts. For this reason, we request that the user configures the max_iteration_steps to be the number of repetitions desired, which unfortunately requires the user to do some extra math (max_iteration_steps = num_examples / batch_size * num_epochs_per_iteration).

Assuming each adanet iteration trains over several epochs, 2. should be less of an issue in practice if your base learners are randomly initialized. They will tend to learn different biases, and form a strong ensemble regardless.

Great! Thanks for the explanation. However, that's sort of not handy to do the math, imagine someone wants to replace the DNNClassifier in her application into adanet.Estimator, there may be lots of work. Will you have a plan to improve this? Or will the Keras version avoid the same situation?

@le-dawg
Copy link

le-dawg commented Apr 19, 2020

@cweill

@shendiaomo: You are correct on both counts. For this reason, we request that the user configures the max_iteration_steps to be the number of repetitions desired, which unfortunately requires the user to do some extra math (max_iteration_steps = num_examples / batch_size * num_epochs_per_iteration).

Assuming each adanet iteration trains over several epochs, 2. should be less of an issue in practice if your base learners are randomly initialized. They will tend to learn different biases, and form a strong ensemble regardless.

From the tutorials:

max_iteration_steps=TRAIN_STEPS // ADANET_ITERATIONS,

If I want to train with 100 epochs over one Adanet iteration, meaning num_examples/batch_size steps per epoch, should I set max_iteration_steps to that value?

I have a sample size of 5265 and batch sizes of 50, so I have about 105 update steps per epoch. Should my max_iteration_steps be 10500?

@le-dawg
Copy link

le-dawg commented Apr 29, 2020

Pinging

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

3 participants