-
Notifications
You must be signed in to change notification settings - Fork 3.4k
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
Trainer.scale_batch_size requires model.batch_size instead of model.hparams.batch_size #2484
Comments
Hi! thanks for your contribution!, great first issue! |
it seems like a nice first issue, @wietsedv mind send a PR? 🐰 |
Appears to be the same with the learning rate parameter. |
A clean fix on the user side while waiting for the PR is to actually use @property
def batch_size(self):
return self.hparams.batch_size
@batch_size.setter
def batch_size(self, batch_size):
self.hparams.batch_size = batch_size That way you keep your hyper parameters together in case you want to dump them somewhere without having to add specific code. |
From #1896 it seems that the problem is rather on the docs side than |
I just tried your fix and it seemed to work :) |
Yes it does work, but from what they said in the PR I linked, |
🐛 Bug
Trainer.scale_batch_size
only works if a model has thebatch_size
property and does not work withmodel.hparams.batch_size
even though all documentation points to the reverse.To Reproduce
All of my hyperparameters are available as model.hparams like suggested in the documentation: (hyperparameters, option 3.
This means that my
batch_size
is available asmodel.hparams.batch_size
.This should be fully compatible with the documented example code of
Trainer.scale_batch_size()
since that code also usesmodel.hparams.batch_size
instead ofmodel.batch_size
.However, when I put my model in
Trainer.scale_batch_size
, I get the following error:Example code
Expected behavior
Either
Trainer.scale_batch_size
should work withmodel.hparams
or the error message, linked documentation examples and docstrings should all change (i.e. here, here and here).(I would prefer the second option. I think that it should work with both
model.batch_size
andmodel.hparams.batch_size
.)Environment
The text was updated successfully, but these errors were encountered: