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
add num_iters in fit/evalate #33986
Conversation
Thanks for your contribution! |
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) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
assert下num_iters需要大于0
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
python/paddle/hapi/model.py
Outdated
@@ -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. |
There was a problem hiding this comment.
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次
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
2a26bf9
to
f98b2bd
Compare
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 |
There was a problem hiding this comment.
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。 这里会出错。
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, PR: #34059
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.