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
5de1517d
Commit
5de1517d
authored
Nov 03, 2018
by
Tim Rault
Browse files
WIP modeling_test_pytorch.py
parent
1ba5b58c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
5 additions
and
8 deletions
+5
-8
modeling_test_pytorch.py
modeling_test_pytorch.py
+5
-8
No files found.
modeling_test_pytorch.py
View file @
5de1517d
...
...
@@ -94,11 +94,10 @@ class BertModelTest(unittest.TestCase):
model
=
modeling
.
BertModel
(
config
=
config
)
all_encoder_layers
,
pooled_output
,
embedding_output
,
sequence_output
=
model
(
input_ids
,
token_type_ids
,
input_mask
)
all_encoder_layers
,
pooled_output
=
model
(
input_ids
,
token_type_ids
,
input_mask
)
outputs
=
{
"embedding_output"
:
embedding_output
,
"sequence_output"
:
sequence_output
,
"sequence_output"
:
all_encoder_layers
[
-
1
],
"pooled_output"
:
pooled_output
,
"all_encoder_layers"
:
all_encoder_layers
,
}
...
...
@@ -106,13 +105,10 @@ class BertModelTest(unittest.TestCase):
def
check_output
(
self
,
result
):
self
.
parent
.
assertListEqual
(
result
[
"embedding_output"
].
shape
,
[
self
.
batch_size
,
self
.
seq_length
,
self
.
hidden_size
])
self
.
parent
.
assertListEqual
(
result
[
"sequence_output"
].
shape
,
list
(
result
[
"sequence_output"
].
size
()),
[
self
.
batch_size
,
self
.
seq_length
,
self
.
hidden_size
])
self
.
parent
.
assertListEqual
(
result
[
"pooled_output"
].
s
hape
,
[
self
.
batch_size
,
self
.
hidden_size
])
self
.
parent
.
assertListEqual
(
list
(
result
[
"pooled_output"
].
s
ize
())
,
[
self
.
batch_size
,
self
.
hidden_size
])
def
test_default
(
self
):
self
.
run_tester
(
BertModelTest
.
BertModelTester
(
self
))
...
...
@@ -144,6 +140,7 @@ class BertModelTest(unittest.TestCase):
for
_
in
range
(
total_dims
):
values
.
append
(
rng
.
randint
(
0
,
vocab_size
-
1
))
# TODO Solve : the returned tensors provoke index out of range errors when passed to the model
return
torch
.
tensor
(
data
=
values
,
dtype
=
torch
.
int32
)
def
assert_all_tensors_reachable
(
self
,
sess
,
outputs
):
...
...
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