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
99e02c34
Unverified
Commit
99e02c34
authored
Apr 23, 2019
by
Thomas Wolf
Committed by
GitHub
Apr 23, 2019
Browse files
Merge pull request #512 from cynthia/master
Fix indentation weirdness in GPT-2 example.
parents
98cb7b2c
14b1f719
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
17 additions
and
19 deletions
+17
-19
examples/run_gpt2.py
examples/run_gpt2.py
+17
-19
No files found.
examples/run_gpt2.py
View file @
99e02c34
...
@@ -107,25 +107,23 @@ def run_model():
...
@@ -107,25 +107,23 @@ def run_model():
print
(
"="
*
40
+
" SAMPLE "
+
str
(
generated
)
+
" "
+
"="
*
40
)
print
(
"="
*
40
+
" SAMPLE "
+
str
(
generated
)
+
" "
+
"="
*
40
)
print
(
text
)
print
(
text
)
print
(
"="
*
80
)
print
(
"="
*
80
)
if
args
.
unconditional
:
else
:
generated
=
0
generated
=
0
for
_
in
range
(
args
.
nsamples
//
args
.
batch_size
):
for
_
in
range
(
args
.
nsamples
//
args
.
batch_size
):
out
=
sample_sequence
(
out
=
sample_sequence
(
model
=
model
,
length
=
args
.
length
,
model
=
model
,
length
=
args
.
length
,
context
=
None
,
context
=
None
,
start_token
=
enc
.
encoder
[
'<|endoftext|>'
],
start_token
=
enc
.
encoder
[
'<|endoftext|>'
],
batch_size
=
args
.
batch_size
,
batch_size
=
args
.
batch_size
,
temperature
=
args
.
temperature
,
top_k
=
args
.
top_k
,
device
=
device
temperature
=
args
.
temperature
,
top_k
=
args
.
top_k
,
device
=
device
)
)
out
=
out
[:,
1
:].
tolist
()
out
=
out
[:,
1
:].
tolist
()
for
i
in
range
(
args
.
batch_size
):
for
i
in
range
(
args
.
batch_size
):
generated
+=
1
generated
+=
1
text
=
enc
.
decode
(
out
[
i
])
text
=
enc
.
decode
(
out
[
i
])
print
(
"="
*
40
+
" SAMPLE "
+
str
(
generated
)
+
" "
+
"="
*
40
)
print
(
"="
*
40
+
" SAMPLE "
+
str
(
generated
)
+
" "
+
"="
*
40
)
print
(
text
)
print
(
text
)
print
(
"="
*
80
)
print
(
"="
*
80
)
if
args
.
unconditional
:
break
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
run_model
()
run_model
()
...
...
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