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
7ffe47c8
Commit
7ffe47c8
authored
Nov 27, 2019
by
piero
Committed by
Julien Chaumond
Dec 03, 2019
Browse files
Improved device specification
parent
4f2164e4
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
6 deletions
+5
-6
examples/run_pplm_discrim_train.py
examples/run_pplm_discrim_train.py
+5
-6
No files found.
examples/run_pplm_discrim_train.py
View file @
7ffe47c8
...
...
@@ -242,10 +242,9 @@ def get_cached_data_loader(dataset, batch_size, discriminator, shuffle=False):
def
train_discriminator
(
dataset
,
dataset_fp
=
None
,
pretrained_model
=
'gpt2-medium'
,
epochs
=
10
,
batch_size
=
64
,
log_interval
=
10
,
save_model
=
False
,
cached
=
False
,
use_cuda
=
False
):
if
use_cuda
:
save_model
=
False
,
cached
=
False
,
no_cuda
=
False
):
global
device
device
=
'cuda'
device
=
"cuda"
if
torch
.
cuda
.
is_available
()
and
not
no_cuda
else
"cpu"
print
(
'Preprocessing {} dataset...'
.
format
(
dataset
))
start
=
time
.
time
()
...
...
@@ -577,8 +576,8 @@ if __name__ == '__main__':
help
=
'whether to save the model'
)
parser
.
add_argument
(
'--cached'
,
action
=
'store_true'
,
help
=
'whether to cache the input representations'
)
parser
.
add_argument
(
'--
use
_cuda'
,
action
=
'store_true'
,
help
=
'use to turn o
n
cuda'
)
parser
.
add_argument
(
'--
no
_cuda'
,
action
=
'store_true'
,
help
=
'use to turn o
ff
cuda'
)
args
=
parser
.
parse_args
()
train_discriminator
(
**
(
vars
(
args
)))
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