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
dc17f2a1
Unverified
Commit
dc17f2a1
authored
Jan 16, 2020
by
Thomas Wolf
Committed by
GitHub
Jan 16, 2020
Browse files
Merge pull request #2538 from huggingface/py3_super
💄
super
parents
88085484
a98b2ca8
Changes
75
Show whitespace changes
Inline
Side-by-side
Showing
15 changed files
with
27 additions
and
27 deletions
+27
-27
templates/adding_a_new_model/modeling_tf_xxx.py
templates/adding_a_new_model/modeling_tf_xxx.py
+7
-7
templates/adding_a_new_model/modeling_xxx.py
templates/adding_a_new_model/modeling_xxx.py
+6
-6
templates/adding_a_new_model/tests/test_tokenization_xxx.py
templates/adding_a_new_model/tests/test_tokenization_xxx.py
+1
-1
templates/adding_a_new_model/tokenization_xxx.py
templates/adding_a_new_model/tokenization_xxx.py
+1
-1
tests/test_tokenization_albert.py
tests/test_tokenization_albert.py
+1
-1
tests/test_tokenization_bert.py
tests/test_tokenization_bert.py
+1
-1
tests/test_tokenization_bert_japanese.py
tests/test_tokenization_bert_japanese.py
+2
-2
tests/test_tokenization_ctrl.py
tests/test_tokenization_ctrl.py
+1
-1
tests/test_tokenization_gpt2.py
tests/test_tokenization_gpt2.py
+1
-1
tests/test_tokenization_openai.py
tests/test_tokenization_openai.py
+1
-1
tests/test_tokenization_roberta.py
tests/test_tokenization_roberta.py
+1
-1
tests/test_tokenization_t5.py
tests/test_tokenization_t5.py
+1
-1
tests/test_tokenization_transfo_xl.py
tests/test_tokenization_transfo_xl.py
+1
-1
tests/test_tokenization_xlm.py
tests/test_tokenization_xlm.py
+1
-1
tests/test_tokenization_xlnet.py
tests/test_tokenization_xlnet.py
+1
-1
No files found.
templates/adding_a_new_model/modeling_tf_xxx.py
View file @
dc17f2a1
...
...
@@ -69,7 +69,7 @@ TFXxxOutput = tf.keras.layers.Layer
class
TFXxxLayer
(
tf
.
keras
.
layers
.
Layer
):
def
__init__
(
self
,
config
,
**
kwargs
):
super
(
TFXxxLayer
,
self
).
__init__
(
**
kwargs
)
super
().
__init__
(
**
kwargs
)
self
.
attention
=
TFXxxAttention
(
config
,
name
=
"attention"
)
self
.
intermediate
=
TFXxxIntermediate
(
config
,
name
=
"intermediate"
)
self
.
transformer_output
=
TFXxxOutput
(
config
,
name
=
"output"
)
...
...
@@ -91,7 +91,7 @@ class TFXxxLayer(tf.keras.layers.Layer):
####################################################
class
TFXxxMainLayer
(
tf
.
keras
.
layers
.
Layer
):
def
__init__
(
self
,
config
,
**
kwargs
):
super
(
TFXxxMainLayer
,
self
).
__init__
(
**
kwargs
)
super
().
__init__
(
**
kwargs
)
def
_resize_token_embeddings
(
self
,
new_num_tokens
):
raise
NotImplementedError
# Not implemented yet in the library fr TF 2.0 models
...
...
@@ -307,7 +307,7 @@ class TFXxxModel(TFXxxPreTrainedModel):
"""
def
__init__
(
self
,
config
,
*
inputs
,
**
kwargs
):
super
(
TFXxxModel
,
self
).
__init__
(
config
,
*
inputs
,
**
kwargs
)
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
transformer
=
TFXxxMainLayer
(
config
,
name
=
"transformer"
)
def
call
(
self
,
inputs
,
**
kwargs
):
...
...
@@ -348,7 +348,7 @@ class TFXxxForMaskedLM(TFXxxPreTrainedModel):
"""
def
__init__
(
self
,
config
,
*
inputs
,
**
kwargs
):
super
(
TFXxxForMaskedLM
,
self
).
__init__
(
config
,
*
inputs
,
**
kwargs
)
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
transformer
=
TFXxxMainLayer
(
config
,
name
=
"transformer"
)
self
.
mlm
=
TFXxxMLMHead
(
config
,
self
.
transformer
.
embeddings
,
name
=
"mlm"
)
...
...
@@ -397,7 +397,7 @@ class TFXxxForSequenceClassification(TFXxxPreTrainedModel):
"""
def
__init__
(
self
,
config
,
*
inputs
,
**
kwargs
):
super
(
TFXxxForSequenceClassification
,
self
).
__init__
(
config
,
*
inputs
,
**
kwargs
)
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
num_labels
=
config
.
num_labels
self
.
transformer
=
TFXxxMainLayer
(
config
,
name
=
"transformer"
)
...
...
@@ -452,7 +452,7 @@ class TFXxxForTokenClassification(TFXxxPreTrainedModel):
"""
def
__init__
(
self
,
config
,
*
inputs
,
**
kwargs
):
super
(
TFXxxForTokenClassification
,
self
).
__init__
(
config
,
*
inputs
,
**
kwargs
)
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
num_labels
=
config
.
num_labels
self
.
transformer
=
TFXxxMainLayer
(
config
,
name
=
"transformer"
)
...
...
@@ -509,7 +509,7 @@ class TFXxxForQuestionAnswering(TFXxxPreTrainedModel):
"""
def
__init__
(
self
,
config
,
*
inputs
,
**
kwargs
):
super
(
TFXxxForQuestionAnswering
,
self
).
__init__
(
config
,
*
inputs
,
**
kwargs
)
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
num_labels
=
config
.
num_labels
self
.
transformer
=
TFXxxMainLayer
(
config
,
name
=
"transformer"
)
...
...
templates/adding_a_new_model/modeling_xxx.py
View file @
dc17f2a1
...
...
@@ -138,7 +138,7 @@ XxxOutput = nn.Module
class
XxxLayer
(
nn
.
Module
):
def
__init__
(
self
,
config
):
super
(
XxxLayer
,
self
).
__init__
()
super
().
__init__
()
self
.
attention
=
XxxAttention
(
config
)
self
.
intermediate
=
XxxIntermediate
(
config
)
self
.
output
=
XxxOutput
(
config
)
...
...
@@ -298,7 +298,7 @@ class XxxModel(XxxPreTrainedModel):
"""
def
__init__
(
self
,
config
):
super
(
XxxModel
,
self
).
__init__
(
config
)
super
().
__init__
(
config
)
self
.
embeddings
=
XxxEmbeddings
(
config
)
self
.
encoder
=
XxxEncoder
(
config
)
...
...
@@ -426,7 +426,7 @@ class XxxForMaskedLM(XxxPreTrainedModel):
"""
def
__init__
(
self
,
config
):
super
(
XxxForMaskedLM
,
self
).
__init__
(
config
)
super
().
__init__
(
config
)
self
.
transformer
=
XxxModel
(
config
)
self
.
lm_head
=
nn
.
Linear
(
config
.
n_embd
,
config
.
vocab_size
)
...
...
@@ -507,7 +507,7 @@ class XxxForSequenceClassification(XxxPreTrainedModel):
"""
def
__init__
(
self
,
config
):
super
(
XxxForSequenceClassification
,
self
).
__init__
(
config
)
super
().
__init__
(
config
)
self
.
num_labels
=
config
.
num_labels
self
.
transformer
=
XxxModel
(
config
)
...
...
@@ -593,7 +593,7 @@ class XxxForTokenClassification(XxxPreTrainedModel):
"""
def
__init__
(
self
,
config
):
super
(
XxxForTokenClassification
,
self
).
__init__
(
config
)
super
().
__init__
(
config
)
self
.
num_labels
=
config
.
num_labels
self
.
transformer
=
XxxModel
(
config
)
...
...
@@ -692,7 +692,7 @@ class XxxForQuestionAnswering(XxxPreTrainedModel):
"""
def
__init__
(
self
,
config
):
super
(
XxxForQuestionAnswering
,
self
).
__init__
(
config
)
super
().
__init__
(
config
)
self
.
num_labels
=
config
.
num_labels
self
.
transformer
=
XxxModel
(
config
)
...
...
templates/adding_a_new_model/tests/test_tokenization_xxx.py
View file @
dc17f2a1
...
...
@@ -27,7 +27,7 @@ class XxxTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
tokenizer_class
=
XxxTokenizer
def
setUp
(
self
):
super
(
XxxTokenizationTest
,
self
).
setUp
()
super
().
setUp
()
vocab_tokens
=
[
"[UNK]"
,
...
...
templates/adding_a_new_model/tokenization_xxx.py
View file @
dc17f2a1
...
...
@@ -109,7 +109,7 @@ class XxxTokenizer(PreTrainedTokenizer):
Whether to lower case the input
Only has an effect when do_basic_tokenize=True
"""
super
(
XxxTokenizer
,
self
).
__init__
(
super
().
__init__
(
unk_token
=
unk_token
,
sep_token
=
sep_token
,
pad_token
=
pad_token
,
...
...
tests/test_tokenization_albert.py
View file @
dc17f2a1
...
...
@@ -30,7 +30,7 @@ class AlbertTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
tokenizer_class
=
AlbertTokenizer
def
setUp
(
self
):
super
(
AlbertTokenizationTest
,
self
).
setUp
()
super
().
setUp
()
# We have a SentencePiece fixture for testing
tokenizer
=
AlbertTokenizer
(
SAMPLE_VOCAB
)
...
...
tests/test_tokenization_bert.py
View file @
dc17f2a1
...
...
@@ -38,7 +38,7 @@ class BertTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
test_rust_tokenizer
=
True
def
setUp
(
self
):
super
(
BertTokenizationTest
,
self
).
setUp
()
super
().
setUp
()
vocab_tokens
=
[
"[UNK]"
,
...
...
tests/test_tokenization_bert_japanese.py
View file @
dc17f2a1
...
...
@@ -35,7 +35,7 @@ class BertJapaneseTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
tokenizer_class
=
BertJapaneseTokenizer
def
setUp
(
self
):
super
(
BertJapaneseTokenizationTest
,
self
).
setUp
()
super
().
setUp
()
vocab_tokens
=
[
"[UNK]"
,
...
...
@@ -135,7 +135,7 @@ class BertJapaneseCharacterTokenizationTest(TokenizerTesterMixin, unittest.TestC
tokenizer_class
=
BertJapaneseTokenizer
def
setUp
(
self
):
super
(
BertJapaneseCharacterTokenizationTest
,
self
).
setUp
()
super
().
setUp
()
vocab_tokens
=
[
"[UNK]"
,
"[CLS]"
,
"[SEP]"
,
"こ"
,
"ん"
,
"に"
,
"ち"
,
"は"
,
"ば"
,
"世"
,
"界"
,
"、"
,
"。"
]
...
...
tests/test_tokenization_ctrl.py
View file @
dc17f2a1
...
...
@@ -27,7 +27,7 @@ class CTRLTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
tokenizer_class
=
CTRLTokenizer
def
setUp
(
self
):
super
(
CTRLTokenizationTest
,
self
).
setUp
()
super
().
setUp
()
# Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
vocab
=
[
"adapt"
,
"re@@"
,
"a@@"
,
"apt"
,
"c@@"
,
"t"
,
"<unk>"
]
...
...
tests/test_tokenization_gpt2.py
View file @
dc17f2a1
...
...
@@ -29,7 +29,7 @@ class GPT2TokenizationTest(TokenizerTesterMixin, unittest.TestCase):
test_rust_tokenizer
=
True
def
setUp
(
self
):
super
(
GPT2TokenizationTest
,
self
).
setUp
()
super
().
setUp
()
# Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
vocab
=
[
...
...
tests/test_tokenization_openai.py
View file @
dc17f2a1
...
...
@@ -28,7 +28,7 @@ class OpenAIGPTTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
tokenizer_class
=
OpenAIGPTTokenizer
def
setUp
(
self
):
super
(
OpenAIGPTTokenizationTest
,
self
).
setUp
()
super
().
setUp
()
# Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
vocab
=
[
...
...
tests/test_tokenization_roberta.py
View file @
dc17f2a1
...
...
@@ -28,7 +28,7 @@ class RobertaTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
tokenizer_class
=
RobertaTokenizer
def
setUp
(
self
):
super
(
RobertaTokenizationTest
,
self
).
setUp
()
super
().
setUp
()
# Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
vocab
=
[
...
...
tests/test_tokenization_t5.py
View file @
dc17f2a1
...
...
@@ -31,7 +31,7 @@ class T5TokenizationTest(TokenizerTesterMixin, unittest.TestCase):
tokenizer_class
=
T5Tokenizer
def
setUp
(
self
):
super
(
T5TokenizationTest
,
self
).
setUp
()
super
().
setUp
()
# We have a SentencePiece fixture for testing
tokenizer
=
T5Tokenizer
(
SAMPLE_VOCAB
)
...
...
tests/test_tokenization_transfo_xl.py
View file @
dc17f2a1
...
...
@@ -33,7 +33,7 @@ class TransfoXLTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
tokenizer_class
=
TransfoXLTokenizer
if
is_torch_available
()
else
None
def
setUp
(
self
):
super
(
TransfoXLTokenizationTest
,
self
).
setUp
()
super
().
setUp
()
vocab_tokens
=
[
"<unk>"
,
...
...
tests/test_tokenization_xlm.py
View file @
dc17f2a1
...
...
@@ -29,7 +29,7 @@ class XLMTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
tokenizer_class
=
XLMTokenizer
def
setUp
(
self
):
super
(
XLMTokenizationTest
,
self
).
setUp
()
super
().
setUp
()
# Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
vocab
=
[
...
...
tests/test_tokenization_xlnet.py
View file @
dc17f2a1
...
...
@@ -31,7 +31,7 @@ class XLNetTokenizationTest(TokenizerTesterMixin, unittest.TestCase):
tokenizer_class
=
XLNetTokenizer
def
setUp
(
self
):
super
(
XLNetTokenizationTest
,
self
).
setUp
()
super
().
setUp
()
# We have a SentencePiece fixture for testing
tokenizer
=
XLNetTokenizer
(
SAMPLE_VOCAB
,
keep_accents
=
True
)
...
...
Prev
1
2
3
4
Next
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