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
290633b8
Commit
290633b8
authored
Nov 04, 2018
by
VictorSanh
Browse files
Fix `args.gradient_accumulation_steps` used before assigment.
parent
649e9774
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
2 deletions
+10
-2
run_classifier.py
run_classifier.py
+5
-1
run_squad.py
run_squad.py
+5
-1
No files found.
run_classifier.py
View file @
290633b8
...
@@ -404,6 +404,10 @@ def main():
...
@@ -404,6 +404,10 @@ def main():
type
=
int
,
type
=
int
,
default
=
42
,
default
=
42
,
help
=
"random seed for initialization"
)
help
=
"random seed for initialization"
)
parser
.
add_argument
(
'--gradient_accumulation_steps'
,
type
=
int
,
default
=
1
,
help
=
"Number of updates steps to accumualte before performing a backward/update pass."
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
processors
=
{
processors
=
{
...
@@ -469,7 +473,7 @@ def main():
...
@@ -469,7 +473,7 @@ def main():
model
=
BertForSequenceClassification
(
bert_config
,
len
(
label_list
))
model
=
BertForSequenceClassification
(
bert_config
,
len
(
label_list
))
if
args
.
init_checkpoint
is
not
None
:
if
args
.
init_checkpoint
is
not
None
:
model
.
load_state_dict
(
torch
.
load
(
args
.
init_checkpoint
,
map_location
=
'cpu'
))
model
.
bert
.
load_state_dict
(
torch
.
load
(
args
.
init_checkpoint
,
map_location
=
'cpu'
))
model
.
to
(
device
)
model
.
to
(
device
)
if
args
.
local_rank
!=
-
1
:
if
args
.
local_rank
!=
-
1
:
...
...
run_squad.py
View file @
290633b8
...
@@ -739,7 +739,11 @@ def main():
...
@@ -739,7 +739,11 @@ def main():
type
=
int
,
type
=
int
,
default
=
42
,
default
=
42
,
help
=
"random seed for initialization"
)
help
=
"random seed for initialization"
)
parser
.
add_argument
(
'--gradient_accumulation_steps'
,
type
=
int
,
default
=
1
,
help
=
"Number of updates steps to accumualte before performing a backward/update pass."
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
if
args
.
local_rank
==
-
1
or
args
.
no_cuda
:
if
args
.
local_rank
==
-
1
or
args
.
no_cuda
:
...
...
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