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
99ae5ab8
Commit
99ae5ab8
authored
Jul 02, 2019
by
thomwolf
Browse files
update config tests and circle-ci
parent
1484d67d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
57 additions
and
2 deletions
+57
-2
.circleci/config.yml
.circleci/config.yml
+2
-2
pytorch_pretrained_bert/modeling_gpt2.py
pytorch_pretrained_bert/modeling_gpt2.py
+13
-0
pytorch_pretrained_bert/modeling_openai.py
pytorch_pretrained_bert/modeling_openai.py
+12
-0
pytorch_pretrained_bert/modeling_transfo_xl.py
pytorch_pretrained_bert/modeling_transfo_xl.py
+11
-0
pytorch_pretrained_bert/modeling_xlnet.py
pytorch_pretrained_bert/modeling_xlnet.py
+12
-0
pytorch_pretrained_bert/tests/model_tests_commons.py
pytorch_pretrained_bert/tests/model_tests_commons.py
+7
-0
No files found.
.circleci/config.yml
View file @
99ae5ab8
...
@@ -10,7 +10,7 @@ jobs:
...
@@ -10,7 +10,7 @@ jobs:
-
run
:
sudo pip install pytest codecov pytest-cov
-
run
:
sudo pip install pytest codecov pytest-cov
-
run
:
sudo pip install spacy ftfy==4.4.3
-
run
:
sudo pip install spacy ftfy==4.4.3
-
run
:
sudo python -m spacy download en
-
run
:
sudo python -m spacy download en
-
run
:
python -m pytest -sv tests/ --cov
-
run
:
python -m pytest -sv
./pytorch_pretrained_bert/
tests/ --cov
-
run
:
codecov
-
run
:
codecov
build_py2
:
build_py2
:
working_directory
:
~/pytorch-pretrained-BERT
working_directory
:
~/pytorch-pretrained-BERT
...
@@ -22,7 +22,7 @@ jobs:
...
@@ -22,7 +22,7 @@ jobs:
-
run
:
sudo pip install pytest codecov pytest-cov
-
run
:
sudo pip install pytest codecov pytest-cov
-
run
:
sudo pip install spacy ftfy==4.4.3
-
run
:
sudo pip install spacy ftfy==4.4.3
-
run
:
sudo python -m spacy download en
-
run
:
sudo python -m spacy download en
-
run
:
python -m pytest -sv tests/ --cov
-
run
:
python -m pytest -sv
./pytorch_pretrained_bert/
tests/ --cov
-
run
:
codecov
-
run
:
codecov
workflows
:
workflows
:
version
:
2
version
:
2
...
...
pytorch_pretrained_bert/modeling_gpt2.py
View file @
99ae5ab8
...
@@ -175,6 +175,19 @@ class GPT2Config(PretrainedConfig):
...
@@ -175,6 +175,19 @@ class GPT2Config(PretrainedConfig):
def
total_tokens_embeddings
(
self
):
def
total_tokens_embeddings
(
self
):
return
self
.
vocab_size
+
self
.
n_special
return
self
.
vocab_size
+
self
.
n_special
@
property
def
hidden_size
(
self
):
return
self
.
n_embd
@
property
def
num_attention_heads
(
self
):
return
self
.
n_head
@
property
def
num_hidden_layers
(
self
):
return
self
.
n_layer
class
Attention
(
nn
.
Module
):
class
Attention
(
nn
.
Module
):
def
__init__
(
self
,
nx
,
n_ctx
,
config
,
scale
=
False
):
def
__init__
(
self
,
nx
,
n_ctx
,
config
,
scale
=
False
):
...
...
pytorch_pretrained_bert/modeling_openai.py
View file @
99ae5ab8
...
@@ -206,6 +206,18 @@ class OpenAIGPTConfig(PretrainedConfig):
...
@@ -206,6 +206,18 @@ class OpenAIGPTConfig(PretrainedConfig):
def
total_tokens_embeddings
(
self
):
def
total_tokens_embeddings
(
self
):
return
self
.
vocab_size
+
self
.
n_special
return
self
.
vocab_size
+
self
.
n_special
@
property
def
hidden_size
(
self
):
return
self
.
n_embd
@
property
def
num_attention_heads
(
self
):
return
self
.
n_head
@
property
def
num_hidden_layers
(
self
):
return
self
.
n_layer
class
Attention
(
nn
.
Module
):
class
Attention
(
nn
.
Module
):
def
__init__
(
self
,
nx
,
n_ctx
,
config
,
scale
=
False
):
def
__init__
(
self
,
nx
,
n_ctx
,
config
,
scale
=
False
):
...
...
pytorch_pretrained_bert/modeling_transfo_xl.py
View file @
99ae5ab8
...
@@ -289,6 +289,17 @@ class TransfoXLConfig(PretrainedConfig):
...
@@ -289,6 +289,17 @@ class TransfoXLConfig(PretrainedConfig):
raise
ValueError
(
"First argument must be either a vocabulary size (int)"
raise
ValueError
(
"First argument must be either a vocabulary size (int)"
"or the path to a pretrained model config file (str)"
)
"or the path to a pretrained model config file (str)"
)
@
property
def
hidden_size
(
self
):
return
self
.
d_model
@
property
def
num_attention_heads
(
self
):
return
self
.
n_head
@
property
def
num_hidden_layers
(
self
):
return
self
.
n_layer
class
PositionalEmbedding
(
nn
.
Module
):
class
PositionalEmbedding
(
nn
.
Module
):
...
...
pytorch_pretrained_bert/modeling_xlnet.py
View file @
99ae5ab8
...
@@ -313,6 +313,18 @@ class XLNetConfig(PretrainedConfig):
...
@@ -313,6 +313,18 @@ class XLNetConfig(PretrainedConfig):
raise
ValueError
(
"First argument must be either a vocabulary size (int)"
raise
ValueError
(
"First argument must be either a vocabulary size (int)"
"or the path to a pretrained model config file (str)"
)
"or the path to a pretrained model config file (str)"
)
@
property
def
hidden_size
(
self
):
return
self
.
d_model
@
property
def
num_attention_heads
(
self
):
return
self
.
n_head
@
property
def
num_hidden_layers
(
self
):
return
self
.
n_layer
try
:
try
:
from
apex.normalization.fused_layer_norm
import
FusedLayerNorm
as
XLNetLayerNorm
from
apex.normalization.fused_layer_norm
import
FusedLayerNorm
as
XLNetLayerNorm
...
...
pytorch_pretrained_bert/tests/model_tests_commons.py
View file @
99ae5ab8
...
@@ -184,6 +184,12 @@ class ConfigTester(object):
...
@@ -184,6 +184,12 @@ class ConfigTester(object):
self
.
config_class
=
config_class
self
.
config_class
=
config_class
self
.
inputs_dict
=
kwargs
self
.
inputs_dict
=
kwargs
def
create_and_test_config_common_properties
(
self
):
config
=
self
.
config_class
(
**
self
.
inputs_dict
)
self
.
parent
.
assertTrue
(
hasattr
(
config
,
'hidden_size'
))
self
.
parent
.
assertTrue
(
hasattr
(
config
,
'num_attention_heads'
))
self
.
parent
.
assertTrue
(
hasattr
(
config
,
'num_hidden_layers'
))
def
create_and_test_config_to_json_string
(
self
):
def
create_and_test_config_to_json_string
(
self
):
config
=
self
.
config_class
(
**
self
.
inputs_dict
)
config
=
self
.
config_class
(
**
self
.
inputs_dict
)
obj
=
json
.
loads
(
config
.
to_json_string
())
obj
=
json
.
loads
(
config
.
to_json_string
())
...
@@ -199,6 +205,7 @@ class ConfigTester(object):
...
@@ -199,6 +205,7 @@ class ConfigTester(object):
self
.
parent
.
assertEqual
(
config_second
.
to_dict
(),
config_first
.
to_dict
())
self
.
parent
.
assertEqual
(
config_second
.
to_dict
(),
config_first
.
to_dict
())
def
run_common_tests
(
self
):
def
run_common_tests
(
self
):
self
.
create_and_test_config_common_properties
()
self
.
create_and_test_config_to_json_string
()
self
.
create_and_test_config_to_json_string
()
self
.
create_and_test_config_to_json_file
()
self
.
create_and_test_config_to_json_file
()
...
...
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