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
Fairseq
Commits
83e08b6f
Commit
83e08b6f
authored
Sep 09, 2018
by
Myle Ott
Browse files
Fix validation loss
parent
bfeb7732
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
fairseq/trainer.py
fairseq/trainer.py
+9
-3
No files found.
fairseq/trainer.py
View file @
83e08b6f
...
@@ -266,17 +266,23 @@ class Trainer(object):
...
@@ -266,17 +266,23 @@ class Trainer(object):
def
valid_step
(
self
,
sample
):
def
valid_step
(
self
,
sample
):
"""Do forward pass in evaluation mode."""
"""Do forward pass in evaluation mode."""
self
.
model
.
eval
()
logging_output
,
sample_size
=
{},
0
with
torch
.
no_grad
():
with
torch
.
no_grad
():
self
.
model
.
eval
()
sample
=
self
.
_prepare_sample
(
sample
)
sample
=
self
.
_prepare_sample
(
sample
)
if
sample
is
None
:
if
sample
is
None
:
sample
=
self
.
_prepare_sample
(
self
.
_dummy_batch
)
sample
=
self
.
_prepare_sample
(
self
.
_dummy_batch
)
ignore_results
=
True
else
:
ignore_results
=
False
_loss
,
sample_size
,
logging_output
=
self
.
task
.
get_loss
(
_loss
,
sample_size
,
logging_output
=
self
.
task
.
get_loss
(
self
.
model
,
self
.
criterion
,
sample
,
self
.
model
,
self
.
criterion
,
sample
,
)
)
if
ignore_results
:
logging_output
,
sample_size
=
{},
0
# gather logging outputs from all replicas
# gather logging outputs from all replicas
if
self
.
args
.
distributed_world_size
>
1
:
if
self
.
args
.
distributed_world_size
>
1
:
logging_output
,
sample_size
=
zip
(
*
distributed_utils
.
all_gather_list
(
logging_output
,
sample_size
=
zip
(
*
distributed_utils
.
all_gather_list
(
...
...
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