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

Remove manual torch.no_grad and train eval mode in LightningModule #1100

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

aniketmaurya
Copy link

PL LightningModule automatically sets train and eval mode and torch.no_grad during the training and validation steps.

self.accumulate_metrics(preds=preds)
self.train()
train_preds = self(xb, yb)
loss = loss_fn(train_preds, yb)
Copy link
Author

Choose a reason for hiding this comment

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

I wasn't able to understand why do we calculate training prediction here?

Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe the name is misleading , these are in fact validation preds. These are used to calculate validation loss and metrics

@codecov
Copy link

codecov bot commented May 16, 2022

Codecov Report

Merging #1100 (13bb3e7) into master (743cb7d) will increase coverage by 0.00%.
The diff coverage is 80.00%.

@@           Coverage Diff           @@
##           master    #1100   +/-   ##
=======================================
  Coverage   85.43%   85.44%           
=======================================
  Files         301      301           
  Lines        6600     6594    -6     
=======================================
- Hits         5639     5634    -5     
+ Misses        961      960    -1     
Flag Coverage Δ
unittests 85.44% <80.00%> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
...odels/ross/efficientdet/lightning/model_adapter.py 37.93% <0.00%> (+1.26%) ⬆️
icevision/models/mmdet/lightning/model_adapter.py 96.96% <100.00%> (-0.26%) ⬇️
...sion/models/torchvision/lightning_model_adapter.py 100.00% <100.00%> (ø)
...dels/ultralytics/yolov5/lightning/model_adapter.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 743cb7d...13bb3e7. Read the comment docs.

@potipot
Copy link
Contributor

potipot commented May 17, 2022

Any idea why black formatting check might failing here?

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

2 participants