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
c14a2227
Commit
c14a2227
authored
Oct 31, 2019
by
Lysandre
Committed by
Lysandre Debut
Nov 26, 2019
Browse files
ALBERT passes all tests
parent
870320a2
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
5 additions
and
10 deletions
+5
-10
transformers/configuration_albert.py
transformers/configuration_albert.py
+1
-3
transformers/modeling_albert.py
transformers/modeling_albert.py
+3
-6
transformers/tests/tokenization_albert_test.py
transformers/tests/tokenization_albert_test.py
+1
-1
No files found.
transformers/configuration_albert.py
View file @
c14a2227
...
@@ -7,7 +7,7 @@ class AlbertConfig(PretrainedConfig):
...
@@ -7,7 +7,7 @@ class AlbertConfig(PretrainedConfig):
"""
"""
def
__init__
(
self
,
def
__init__
(
self
,
vocab_size_or_config_json_file
,
vocab_size_or_config_json_file
=
30000
,
embedding_size
=
128
,
embedding_size
=
128
,
hidden_size
=
4096
,
hidden_size
=
4096
,
num_hidden_layers
=
12
,
num_hidden_layers
=
12
,
...
@@ -15,7 +15,6 @@ class AlbertConfig(PretrainedConfig):
...
@@ -15,7 +15,6 @@ class AlbertConfig(PretrainedConfig):
num_attention_heads
=
64
,
num_attention_heads
=
64
,
intermediate_size
=
16384
,
intermediate_size
=
16384
,
inner_group_num
=
1
,
inner_group_num
=
1
,
down_scale_factor
=
1
,
hidden_act
=
"gelu_new"
,
hidden_act
=
"gelu_new"
,
hidden_dropout_prob
=
0
,
hidden_dropout_prob
=
0
,
attention_probs_dropout_prob
=
0
,
attention_probs_dropout_prob
=
0
,
...
@@ -61,7 +60,6 @@ class AlbertConfig(PretrainedConfig):
...
@@ -61,7 +60,6 @@ class AlbertConfig(PretrainedConfig):
self
.
num_hidden_groups
=
num_hidden_groups
self
.
num_hidden_groups
=
num_hidden_groups
self
.
num_attention_heads
=
num_attention_heads
self
.
num_attention_heads
=
num_attention_heads
self
.
inner_group_num
=
inner_group_num
self
.
inner_group_num
=
inner_group_num
self
.
down_scale_factor
=
down_scale_factor
self
.
hidden_act
=
hidden_act
self
.
hidden_act
=
hidden_act
self
.
intermediate_size
=
intermediate_size
self
.
intermediate_size
=
intermediate_size
self
.
hidden_dropout_prob
=
hidden_dropout_prob
self
.
hidden_dropout_prob
=
hidden_dropout_prob
...
...
transformers/modeling_albert.py
View file @
c14a2227
...
@@ -202,17 +202,14 @@ class AlbertLayerGroup(nn.Module):
...
@@ -202,17 +202,14 @@ class AlbertLayerGroup(nn.Module):
layer_attentions
=
()
layer_attentions
=
()
for
albert_layer
in
self
.
albert_layers
:
for
albert_layer
in
self
.
albert_layers
:
if
self
.
output_hidden_states
:
layer_hidden_states
=
layer_hidden_states
+
(
hidden_states
,)
layer_output
=
albert_layer
(
hidden_states
,
attention_mask
,
head_mask
)
layer_output
=
albert_layer
(
hidden_states
,
attention_mask
,
head_mask
)
hidden_states
=
layer_output
[
0
]
hidden_states
=
layer_output
[
0
]
if
self
.
output_attentions
:
if
self
.
output_attentions
:
layer_attentions
=
layer_attentions
+
(
layer_output
[
1
],)
layer_attentions
=
layer_attentions
+
(
layer_output
[
1
],)
if
self
.
output_hidden_states
:
if
self
.
output_hidden_states
:
layer_hidden_states
=
layer_hidden_states
+
(
hidden_states
,)
layer_hidden_states
=
layer_hidden_states
+
(
hidden_states
,)
outputs
=
(
hidden_states
,)
outputs
=
(
hidden_states
,)
if
self
.
output_hidden_states
:
if
self
.
output_hidden_states
:
...
@@ -247,7 +244,7 @@ class AlbertTransformer(nn.Module):
...
@@ -247,7 +244,7 @@ class AlbertTransformer(nn.Module):
hidden_states
=
layer_group_output
[
0
]
hidden_states
=
layer_group_output
[
0
]
if
self
.
output_attentions
:
if
self
.
output_attentions
:
all_attentions
=
all_attentions
+
layer_group_output
[
1
]
all_attentions
=
all_attentions
+
layer_group_output
[
-
1
]
if
self
.
output_hidden_states
:
if
self
.
output_hidden_states
:
all_hidden_states
=
all_hidden_states
+
(
hidden_states
,)
all_hidden_states
=
all_hidden_states
+
(
hidden_states
,)
...
...
transformers/tests/tokenization_albert_test.py
View file @
c14a2227
...
@@ -22,7 +22,7 @@ from transformers.tokenization_albert import (AlbertTokenizer, SPIECE_UNDERLINE)
...
@@ -22,7 +22,7 @@ from transformers.tokenization_albert import (AlbertTokenizer, SPIECE_UNDERLINE)
from
.tokenization_tests_commons
import
CommonTestCases
from
.tokenization_tests_commons
import
CommonTestCases
SAMPLE_VOCAB
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
SAMPLE_VOCAB
=
os
.
path
.
join
(
os
.
path
.
dirname
(
os
.
path
.
abspath
(
__file__
)),
'fixtures/
30k-clean
.model'
)
'fixtures/
spiece
.model'
)
class
AlbertTokenizationTest
(
CommonTestCases
.
CommonTokenizerTester
):
class
AlbertTokenizationTest
(
CommonTestCases
.
CommonTokenizerTester
):
...
...
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