Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
chenpangpang
transformers
Commits
a1af5247
Commit
a1af5247
authored
Nov 03, 2018
by
VictorSanh
Browse files
Add seed in initialization
parent
4faeb38b
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
19 additions
and
2 deletions
+19
-2
run_classifier_pytorch.py
run_classifier_pytorch.py
+10
-2
run_squad_pytorch.py
run_squad_pytorch.py
+9
-0
No files found.
run_classifier_pytorch.py
View file @
a1af5247
...
@@ -427,7 +427,10 @@ def main():
...
@@ -427,7 +427,10 @@ def main():
type
=
int
,
type
=
int
,
default
=-
1
,
default
=-
1
,
help
=
"local_rank for distributed training on gpus"
)
help
=
"local_rank for distributed training on gpus"
)
parser
.
add_argument
(
'--seed'
,
type
=
int
,
default
=
42
,
help
=
"random seed for initialization"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
processors
=
{
processors
=
{
...
@@ -444,7 +447,12 @@ def main():
...
@@ -444,7 +447,12 @@ def main():
n_gpu
=
1
n_gpu
=
1
# print("Initializing the distributed backend: NCCL")
# print("Initializing the distributed backend: NCCL")
print
(
"device"
,
device
,
"n_gpu"
,
n_gpu
)
print
(
"device"
,
device
,
"n_gpu"
,
n_gpu
)
random
.
seed
(
args
.
seed
)
np
.
random
.
seed
(
args
.
seed
)
torch
.
manual_seed
(
args
.
seed
)
if
n_gpu
>
0
:
torch
.
cuda
.
manual_seed_all
(
args
.
seed
)
if
not
args
.
do_train
and
not
args
.
do_eval
:
if
not
args
.
do_train
and
not
args
.
do_eval
:
raise
ValueError
(
"At least one of `do_train` or `do_eval` must be True."
)
raise
ValueError
(
"At least one of `do_train` or `do_eval` must be True."
)
...
...
run_squad_pytorch.py
View file @
a1af5247
...
@@ -745,6 +745,10 @@ def main():
...
@@ -745,6 +745,10 @@ def main():
type
=
int
,
type
=
int
,
default
=-
1
,
default
=-
1
,
help
=
"local_rank for distributed training on gpus"
)
help
=
"local_rank for distributed training on gpus"
)
parser
.
add_argument
(
'--seed'
,
type
=
int
,
default
=
42
,
help
=
"random seed for initialization"
)
args
=
parser
.
parse_args
()
args
=
parser
.
parse_args
()
...
@@ -757,6 +761,11 @@ def main():
...
@@ -757,6 +761,11 @@ def main():
# print("Initializing the distributed backend: NCCL")
# print("Initializing the distributed backend: NCCL")
print
(
"device"
,
device
,
"n_gpu"
,
n_gpu
)
print
(
"device"
,
device
,
"n_gpu"
,
n_gpu
)
random
.
seed
(
args
.
seed
)
np
.
random
.
seed
(
args
.
seed
)
torch
.
manual_seed
(
args
.
seed
)
if
n_gpu
>
0
:
torch
.
cuda
.
manual_seed_all
(
args
.
seed
)
if
not
args
.
do_train
and
not
args
.
do_predict
:
if
not
args
.
do_train
and
not
args
.
do_predict
:
raise
ValueError
(
"At least one of `do_train` or `do_predict` must be True."
)
raise
ValueError
(
"At least one of `do_train` or `do_predict` must be True."
)
...
...
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