Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
MMCV
Commits
daab369e
Unverified
Commit
daab369e
authored
Jan 08, 2021
by
Zhiyuan Chen
Committed by
GitHub
Jan 08, 2021
Browse files
Add torch.no_grad() decorator to the whole val workflow(#777)
parent
477f0c0a
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
mmcv/runner/epoch_based_runner.py
mmcv/runner/epoch_based_runner.py
+2
-2
No files found.
mmcv/runner/epoch_based_runner.py
View file @
daab369e
...
...
@@ -54,6 +54,7 @@ class EpochBasedRunner(BaseRunner):
self
.
call_hook
(
'after_train_epoch'
)
self
.
_epoch
+=
1
@
torch
.
no_grad
()
def
val
(
self
,
data_loader
,
**
kwargs
):
self
.
model
.
eval
()
self
.
mode
=
'val'
...
...
@@ -63,8 +64,7 @@ class EpochBasedRunner(BaseRunner):
for
i
,
data_batch
in
enumerate
(
self
.
data_loader
):
self
.
_inner_iter
=
i
self
.
call_hook
(
'before_val_iter'
)
with
torch
.
no_grad
():
self
.
run_iter
(
data_batch
,
train_mode
=
False
)
self
.
run_iter
(
data_batch
,
train_mode
=
False
)
self
.
call_hook
(
'after_val_iter'
)
self
.
call_hook
(
'after_val_epoch'
)
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment