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
335f57ba
Commit
335f57ba
authored
Jun 18, 2019
by
thomwolf
Browse files
only on main process
parent
326944d6
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
3 deletions
+5
-3
examples/run_squad.py
examples/run_squad.py
+5
-3
No files found.
examples/run_squad.py
View file @
335f57ba
...
...
@@ -917,6 +917,7 @@ def main():
model
=
torch
.
nn
.
DataParallel
(
model
)
if
args
.
do_train
:
if
args
.
local_rank
in
[
-
1
,
0
]:
writer
=
SummaryWriter
()
# Prepare data loader
train_examples
=
read_squad_examples
(
...
...
@@ -1016,6 +1017,7 @@ def main():
else
:
loss
.
backward
()
if
(
step
+
1
)
%
args
.
gradient_accumulation_steps
==
0
:
if
args
.
local_rank
in
[
-
1
,
0
]:
writer
.
add_scalar
(
'lr'
,
optimizer
.
get_lr
()[
0
],
global_step
)
writer
.
add_scalar
(
'loss'
,
loss
.
item
(),
global_step
)
if
args
.
fp16
:
...
...
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