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
511bce58
Commit
511bce58
authored
Nov 30, 2018
by
thomwolf
Browse files
update new token classification model
parent
258eb500
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
2 additions
and
2 deletions
+2
-2
pytorch_pretrained_bert/modeling.py
pytorch_pretrained_bert/modeling.py
+2
-2
No files found.
pytorch_pretrained_bert/modeling.py
View file @
511bce58
...
@@ -932,8 +932,8 @@ class BertForTokenClassification(PreTrainedBertModel):
...
@@ -932,8 +932,8 @@ class BertForTokenClassification(PreTrainedBertModel):
def
forward
(
self
,
input_ids
,
token_type_ids
=
None
,
attention_mask
=
None
,
labels
=
None
):
def
forward
(
self
,
input_ids
,
token_type_ids
=
None
,
attention_mask
=
None
,
labels
=
None
):
sequence_output
,
_
=
self
.
bert
(
input_ids
,
token_type_ids
,
attention_mask
,
output_all_encoded_layers
=
False
)
sequence_output
,
_
=
self
.
bert
(
input_ids
,
token_type_ids
,
attention_mask
,
output_all_encoded_layers
=
False
)
pooled
_output
=
self
.
dropout
(
sequence_output
)
sequence
_output
=
self
.
dropout
(
sequence_output
)
logits
=
self
.
classifier
(
pooled
_output
)
logits
=
self
.
classifier
(
sequence
_output
)
if
labels
is
not
None
:
if
labels
is
not
None
:
loss_fct
=
CrossEntropyLoss
()
loss_fct
=
CrossEntropyLoss
()
...
...
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