Skip to content

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

Open
aniketmaurya wants to merge 2 commits into
airctic:masterfrom
aniketmaurya:refactor-lit
Open

Remove manual torch.no_grad and train eval mode in LightningModule#1100
aniketmaurya wants to merge 2 commits into
airctic:masterfrom
aniketmaurya:refactor-lit

Conversation

@aniketmaurya

Copy link
Copy Markdown

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
Copy Markdown
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
Copy Markdown
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

codecov Bot commented May 16, 2022

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 80.00000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.44%. Comparing base (743cb7d) to head (13bb3e7).
⚠️ Report is 17 commits behind head on master.

Files with missing lines Patch % Lines
...odels/ross/efficientdet/lightning/model_adapter.py 0.00% 3 Missing ⚠️
Additional details and impacted files
@@           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.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
@potipot

potipot commented May 17, 2022

Copy link
Copy Markdown
Contributor

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

2 participants