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

add num_iters in fit/evalate #33986

Merged
merged 2 commits into from Jul 8, 2021

Conversation

ghostxsl
Copy link
Contributor

@ghostxsl ghostxsl commented Jul 6, 2021

PR types

Others

PR changes

Others

Describe

In the hapi, .fit() and .evaluate() is based on epoch, which is troublesome when users want to train a few iterations.

@paddle-bot-old
Copy link

paddle-bot-old bot commented Jul 6, 2021

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

self.num_iters = num_iters
if num_iters is not None and isinstance(num_iters, int):
epochs = (num_iters // steps) + 1
steps = min(num_iters, steps)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

assert下num_iters需要大于0

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@@ -1581,6 +1581,8 @@ def fit(
accumulate_grad_batches (int): The number of batches to accumulate gradident
during training process before optimizer updates. It can mimic large batch
size. Default: 1.
num_iters (int|None): Integer number. The number of iterations to train
the model. If None, follow `epochs` to train the model. Default: None.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

说明一下None的时候会训练整个epoch,非None的时候训练num_iters次

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

@heavengate heavengate changed the title add num_iters in fit/evalate, test=develop add num_iters in fit/evalate Jul 8, 2021
@heavengate heavengate merged commit 97faf90 into PaddlePaddle:develop Jul 8, 2021
self.num_iters = num_iters
if num_iters is not None and isinstance(num_iters, int):
assert num_iters > 0, "num_iters must be greater than 0!"
epochs = (num_iters // steps) + 1
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

data loader是iterable style时, steps是None。 这里会出错。

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done, PR: #34059

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

Successfully merging this pull request may close these issues.

None yet

3 participants