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
b3d83d68
Commit
b3d83d68
authored
Aug 12, 2019
by
Julien Chaumond
Browse files
Fixup
9d060314
parent
75d5f98f
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
1 deletion
+4
-1
pytorch_transformers/convert_roberta_checkpoint_to_pytorch.py
...rch_transformers/convert_roberta_checkpoint_to_pytorch.py
+4
-1
No files found.
pytorch_transformers/convert_roberta_checkpoint_to_pytorch.py
View file @
b3d83d68
...
...
@@ -139,7 +139,10 @@ def convert_roberta_checkpoint_to_pytorch(roberta_checkpoint_path, pytorch_dump_
input_ids
:
torch
.
Tensor
=
roberta
.
encode
(
SAMPLE_TEXT
).
unsqueeze
(
0
)
# batch of size 1
our_output
=
model
(
input_ids
)[
0
]
their_output
=
roberta
.
model
(
input_ids
)[
0
]
if
classification_head
:
their_output
=
roberta
.
model
.
classification_heads
[
'mnli'
](
roberta
.
extract_features
(
input_ids
))
else
:
their_output
=
roberta
.
model
(
input_ids
)[
0
]
print
(
our_output
.
shape
,
their_output
.
shape
)
success
=
torch
.
allclose
(
our_output
,
their_output
,
atol
=
1e-3
)
print
(
...
...
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