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
804cd185
Unverified
Commit
804cd185
authored
Feb 04, 2021
by
Daniel Hug
Committed by
GitHub
Feb 04, 2021
Browse files
Added Integration testing for DistilBert model from issue #9948' (#9995)
parent
00031785
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
18 additions
and
0 deletions
+18
-0
tests/test_modeling_distilbert.py
tests/test_modeling_distilbert.py
+18
-0
No files found.
tests/test_modeling_distilbert.py
View file @
804cd185
...
@@ -24,6 +24,8 @@ from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention
...
@@ -24,6 +24,8 @@ from .test_modeling_common import ModelTesterMixin, ids_tensor, random_attention
if
is_torch_available
():
if
is_torch_available
():
import
torch
from
transformers
import
(
from
transformers
import
(
DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST
,
DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST
,
DistilBertConfig
,
DistilBertConfig
,
...
@@ -246,3 +248,19 @@ class DistilBertModelTest(ModelTesterMixin, unittest.TestCase):
...
@@ -246,3 +248,19 @@ class DistilBertModelTest(ModelTesterMixin, unittest.TestCase):
for
model_name
in
DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST
[:
1
]:
for
model_name
in
DISTILBERT_PRETRAINED_MODEL_ARCHIVE_LIST
[:
1
]:
model
=
DistilBertModel
.
from_pretrained
(
model_name
)
model
=
DistilBertModel
.
from_pretrained
(
model_name
)
self
.
assertIsNotNone
(
model
)
self
.
assertIsNotNone
(
model
)
@
require_torch
class
DistilBertModelIntergrationTest
(
unittest
.
TestCase
):
@
slow
def
test_inference_no_head_absolute_embedding
(
self
):
model
=
DistilBertModel
.
from_pretrained
(
"distilbert-base-uncased"
)
input_ids
=
torch
.
tensor
([[
0
,
345
,
232
,
328
,
740
,
140
,
1695
,
69
,
6078
,
1588
,
2
]])
output
=
model
(
input_ids
)[
0
]
expected_shape
=
torch
.
Size
((
1
,
11
,
768
))
self
.
assertEqual
(
output
.
shape
,
expected_shape
)
expected_slice
=
torch
.
tensor
(
[[[
0.4026
,
-
0.2919
,
0.3902
],
[
0.3828
,
-
0.2129
,
0.3563
],
[
0.3919
,
-
0.2287
,
0.3438
]]]
)
self
.
assertTrue
(
torch
.
allclose
(
output
[:,
:
3
,
:
3
],
expected_slice
,
atol
=
1e-4
))
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