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
8abfee9e
Commit
8abfee9e
authored
Oct 08, 2019
by
Rémi Louf
Browse files
rename Bert2Bert -> Bert2Rnd
parent
82628b0f
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
7 additions
and
6 deletions
+7
-6
transformers/__init__.py
transformers/__init__.py
+1
-1
transformers/modeling_bert.py
transformers/modeling_bert.py
+4
-3
transformers/tests/modeling_bert_test.py
transformers/tests/modeling_bert_test.py
+2
-2
No files found.
transformers/__init__.py
View file @
8abfee9e
...
...
@@ -64,7 +64,7 @@ if is_torch_available():
BertForMaskedLM
,
BertForNextSentencePrediction
,
BertForSequenceClassification
,
BertForMultipleChoice
,
BertForTokenClassification
,
BertForQuestionAnswering
,
load_tf_weights_in_bert
,
BERT_PRETRAINED_MODEL_ARCHIVE_MAP
,
Bert2
Bert
)
load_tf_weights_in_bert
,
BERT_PRETRAINED_MODEL_ARCHIVE_MAP
,
Bert2
Rnd
)
from
.modeling_openai
import
(
OpenAIGPTPreTrainedModel
,
OpenAIGPTModel
,
OpenAIGPTLMHeadModel
,
OpenAIGPTDoubleHeadsModel
,
load_tf_weights_in_openai_gpt
,
OPENAI_GPT_PRETRAINED_MODEL_ARCHIVE_MAP
)
...
...
transformers/modeling_bert.py
View file @
8abfee9e
...
...
@@ -1419,7 +1419,7 @@ class BertForQuestionAnswering(BertPreTrainedModel):
@
add_start_docstrings
(
"Bert encoder-decoder model for sequence generation."
,
BERT_START_DOCSTRING
,
BERT_INPUTS_DOCSTRING
)
class
Bert2
Bert
(
BertPreTrainedModel
):
class
Bert2
Rnd
(
BertPreTrainedModel
):
r
"""
Outputs: `Tuple` comprising various elements depending on the configuration (config) and inputs:
...
...
@@ -1434,7 +1434,8 @@ class Bert2Bert(BertPreTrainedModel):
Examples::
tokenizer = BertTokenizer.from_pretrained('bert-base-uncased')
model = Bert2Bert.from_pretrained('bert-base-uncased')
model = Bert2Rnd.from_pretrained('bert-base-uncased')
# fine-tuning magic happens here
input = tokenizer.encode("Hello, how are you?")
outputs = model(input)
output_text = tokenize.decode(outputs[0])
...
...
@@ -1468,4 +1469,4 @@ class Bert2Bert(BertPreTrainedModel):
token_type_ids
=
token_type_ids
,
position_ids
=
position_ids
,
head_mask
=
head_mask
)
return
decoder_outputs
return
decoder_outputs
[
0
]
transformers/tests/modeling_bert_test.py
View file @
8abfee9e
...
...
@@ -29,7 +29,7 @@ if is_torch_available():
from
transformers
import
(
BertConfig
,
BertModel
,
BertForMaskedLM
,
BertForNextSentencePrediction
,
BertForPreTraining
,
BertForQuestionAnswering
,
BertForSequenceClassification
,
BertForTokenClassification
,
BertForMultipleChoice
,
Bert2
Bert
)
BertForTokenClassification
,
BertForMultipleChoice
,
Bert2
Rnd
)
from
transformers.modeling_bert
import
BERT_PRETRAINED_MODEL_ARCHIVE_MAP
else
:
pytestmark
=
pytest
.
mark
.
skip
(
"Require Torch"
)
...
...
@@ -257,7 +257,7 @@ class BertModelTest(CommonTestCases.CommonModelTester):
def
create_and_check_bert2bert
(
self
,
config
,
input_ids
,
token_type_ids
,
input_mask
,
sequence_labels
,
token_labels
,
choice_labels
):
config
.
num_choices
=
self
.
num_choices
model
=
Bert2
Bert
(
config
=
config
)
model
=
Bert2
Rnd
(
config
=
config
)
model
.
eval
()
bert2bert_inputs_ids
=
input_ids
.
unsqueeze
(
1
).
expand
(
-
1
,
self
.
num_choices
,
-
1
).
contiguous
()
bert2bert_token_type_ids
=
token_type_ids
.
unsqueeze
(
1
).
expand
(
-
1
,
self
.
num_choices
,
-
1
).
contiguous
()
...
...
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