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
Hide 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,7 +917,8 @@ def main():
model
=
torch
.
nn
.
DataParallel
(
model
)
if
args
.
do_train
:
writer
=
SummaryWriter
()
if
args
.
local_rank
in
[
-
1
,
0
]:
writer
=
SummaryWriter
()
# Prepare data loader
train_examples
=
read_squad_examples
(
input_file
=
args
.
train_file
,
is_training
=
True
,
version_2_with_negative
=
args
.
version_2_with_negative
)
...
...
@@ -1016,8 +1017,9 @@ def main():
else
:
loss
.
backward
()
if
(
step
+
1
)
%
args
.
gradient_accumulation_steps
==
0
:
writer
.
add_scalar
(
'lr'
,
optimizer
.
get_lr
()[
0
],
global_step
)
writer
.
add_scalar
(
'loss'
,
loss
.
item
(),
global_step
)
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
:
# modify learning rate with special warm up BERT uses
# if args.fp16 is False, BertAdam is used and handles this automatically
...
...
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