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
chenpangpang
transformers
Commits
c153bcc5
Unverified
Commit
c153bcc5
authored
Oct 26, 2020
by
luyug
Committed by
GitHub
Oct 26, 2020
Browse files
Add mixed precision evaluation (#8036)
* Add mixed precision evaluation * use original flag
parent
9aa28266
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
1 deletion
+5
-1
src/transformers/trainer.py
src/transformers/trainer.py
+5
-1
No files found.
src/transformers/trainer.py
View file @
c153bcc5
...
@@ -1466,7 +1466,11 @@ class Trainer:
...
@@ -1466,7 +1466,11 @@ class Trainer:
inputs
=
self
.
_prepare_inputs
(
inputs
)
inputs
=
self
.
_prepare_inputs
(
inputs
)
with
torch
.
no_grad
():
with
torch
.
no_grad
():
outputs
=
model
(
**
inputs
)
if
self
.
args
.
fp16
and
_use_native_amp
:
with
autocast
():
outputs
=
model
(
**
inputs
)
else
:
outputs
=
model
(
**
inputs
)
if
has_labels
:
if
has_labels
:
loss
=
outputs
[
0
].
mean
().
detach
()
loss
=
outputs
[
0
].
mean
().
detach
()
logits
=
outputs
[
1
:]
logits
=
outputs
[
1
:]
...
...
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