-
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
Deprecate @auto_move_data
in favor of trainer.predict
#6993
Conversation
@auto_move_data
in favor of trainer.predict
@auto_move_data
in favor of trainer.predict
Codecov Report
@@ Coverage Diff @@
## master #6993 +/- ##
========================================
- Coverage 92% 83% -9%
========================================
Files 194 194
Lines 12328 13236 +908
========================================
- Hits 11324 10993 -331
- Misses 1004 2243 +1239 |
I am finding some trouble with #this
trainer.predict(model, target)
# and this:
model.eval()
trainer.predict(model, target) But even with # this
def predictions(model, inputs):
model.eval()
with torch.no_grad():
preds = model(inputs)
model.train()
return preds
predictions(model, test_data)
# or this
model.predict(test_data, batch_idx=1) # as my model is from pl.lightining module, batch_id can be whatever The question is, why Just to note, in my pl model i just implemented the |
Hi @dsantiago, can you open a separate issue about this? A reproduction snippet would also be greatly appreciated. |
Hi @carmocca it's just a point, not an error, i am just asking if is it OK for Trainer.predict() run Dropout and BatchNorm layers, because for me it's counter intuitive.... But i can always rely in calling model directly, with model.eval() + torch.nograd() or use the pytorch lightning model's predict() function... It's just to reflect... |
It should be getting called: So if it is not, it's an error. So please, try to reproduce it and open an issue about it 😃 |
I saw that part of the code when trying to understand, and it really just disable the grad calculation, if the model isn't in eval mode, it will continue to run Dropouts and BatchNorm layers... Just one call to model.eval() before getting the model predictions and put it on model.train() back after should make de deal(like in the predictions() function i did above). |
|
Well i removed some boilerplate code so you can verify if u wish, dont need to add gpus as the network is kind of small. Maybe i am missing the point from my side |
I know what the problem is with your code @dsantiago, but let's not discuss that here. Please open a discussion (discussion tab on top next to Pull Requests) ping me there. |
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.
😢 😢 😢
Thanks @awaelchli , did it now! Thanks for your time in seeing it! |
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.
LGTM !
What does this PR do?
See title.
This was added in 0.8.0.
A quick code search shows some users of this feature, but many don't use it correctly or assume it's required. Additionally, we want people to use
predict
.Also improves predict docs.
Before submitting
PR review