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
96d21ad0
Commit
96d21ad0
authored
Jan 17, 2020
by
Lysandre
Committed by
Lysandre Debut
Jan 23, 2020
Browse files
TF OpenAI GPT
parent
850795c4
Changes
3
Expand all
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
175 additions
and
151 deletions
+175
-151
src/transformers/modeling_tf_bert.py
src/transformers/modeling_tf_bert.py
+34
-35
src/transformers/modeling_tf_gpt2.py
src/transformers/modeling_tf_gpt2.py
+3
-0
src/transformers/modeling_tf_openai.py
src/transformers/modeling_tf_openai.py
+138
-116
No files found.
src/transformers/modeling_tf_bert.py
View file @
96d21ad0
...
...
@@ -660,6 +660,13 @@ BERT_INPUTS_DOCSTRING = r"""
BERT_START_DOCSTRING
,
)
class
TFBertModel
(
TFBertPreTrainedModel
):
def
__init__
(
self
,
config
,
*
inputs
,
**
kwargs
):
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
bert
=
TFBertMainLayer
(
config
,
name
=
"bert"
)
@
add_start_docstrings_to_callable
(
BERT_INPUTS_DOCSTRING
)
def
call
(
self
,
inputs
,
**
kwargs
):
r
"""
Returns:
:obj:`tuple(tf.Tensor)` comprising various elements depending on the configuration (:class:`~transformers.BertConfig`) and inputs:
...
...
@@ -693,15 +700,7 @@ class TFBertModel(TFBertPreTrainedModel):
input_ids = tf.constant(tokenizer.encode("Hello, my dog is cute", add_special_tokens=True))[None, :] # Batch size 1
outputs = model(input_ids)
last_hidden_states = outputs[0] # The last hidden-state is the first element of the output tuple
"""
def
__init__
(
self
,
config
,
*
inputs
,
**
kwargs
):
super
().
__init__
(
config
,
*
inputs
,
**
kwargs
)
self
.
bert
=
TFBertMainLayer
(
config
,
name
=
"bert"
)
@
add_start_docstrings_to_callable
(
BERT_INPUTS_DOCSTRING
)
def
call
(
self
,
inputs
,
**
kwargs
):
outputs
=
self
.
bert
(
inputs
,
**
kwargs
)
return
outputs
...
...
src/transformers/modeling_tf_gpt2.py
View file @
96d21ad0
...
...
@@ -433,6 +433,9 @@ GPT2_INPUTS_DOCSTRING = r"""
Optionally, instead of passing :obj:`input_ids` you can choose to directly pass an embedded representation.
This is useful if you want more control over how to convert `input_ids` indices into associated vectors
than the model's internal embedding lookup matrix.
training (:obj:`boolean`, `optional`, defaults to :obj:`False`):
Whether to activate dropout modules (if set to :obj:`True`) during training or to de-activate them
(if set to :obj:`False`) for evaluation.
"""
...
...
src/transformers/modeling_tf_openai.py
View file @
96d21ad0
This diff is collapsed.
Click to expand it.
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