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
17d7aec8
Unverified
Commit
17d7aec8
authored
Oct 20, 2022
by
IMvision12
Committed by
GitHub
Oct 20, 2022
Browse files
Update modeling_layoutlmv3.py (#19753)
parent
a4038666
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
41 additions
and
40 deletions
+41
-40
src/transformers/models/layoutlmv3/modeling_layoutlmv3.py
src/transformers/models/layoutlmv3/modeling_layoutlmv3.py
+41
-40
No files found.
src/transformers/models/layoutlmv3/modeling_layoutlmv3.py
View file @
17d7aec8
...
@@ -16,6 +16,7 @@
...
@@ -16,6 +16,7 @@
import
collections
import
collections
import
math
import
math
from
typing
import
Optional
,
Tuple
,
Union
import
torch
import
torch
import
torch.nn
as
nn
import
torch.nn
as
nn
...
@@ -1061,19 +1062,19 @@ class LayoutLMv3ForTokenClassification(LayoutLMv3PreTrainedModel):
...
@@ -1061,19 +1062,19 @@ class LayoutLMv3ForTokenClassification(LayoutLMv3PreTrainedModel):
@
replace_return_docstrings
(
output_type
=
TokenClassifierOutput
,
config_class
=
_CONFIG_FOR_DOC
)
@
replace_return_docstrings
(
output_type
=
TokenClassifierOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
def
forward
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
bbox
=
None
,
bbox
:
Optional
[
torch
.
LongTensor
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
position_ids
=
None
,
position_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
head_mask
=
None
,
head_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
torch
.
FloatTensor
]
=
None
,
labels
=
None
,
labels
:
Optional
[
torch
.
LongTensor
]
=
None
,
output_attentions
=
None
,
output_attentions
:
Optional
[
bool
]
=
None
,
output_hidden_states
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
pixel_values
=
None
,
pixel_values
:
Optional
[
torch
.
LongTensor
]
=
None
,
):
)
->
Union
[
Tuple
,
TokenClassifierOutput
]
:
r
"""
r
"""
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
labels (`torch.LongTensor` of shape `(batch_size, sequence_length)`, *optional*):
Labels for computing the token classification loss. Indices should be in `[0, ..., config.num_labels - 1]`.
Labels for computing the token classification loss. Indices should be in `[0, ..., config.num_labels - 1]`.
...
@@ -1172,20 +1173,20 @@ class LayoutLMv3ForQuestionAnswering(LayoutLMv3PreTrainedModel):
...
@@ -1172,20 +1173,20 @@ class LayoutLMv3ForQuestionAnswering(LayoutLMv3PreTrainedModel):
@
replace_return_docstrings
(
output_type
=
QuestionAnsweringModelOutput
,
config_class
=
_CONFIG_FOR_DOC
)
@
replace_return_docstrings
(
output_type
=
QuestionAnsweringModelOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
def
forward
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
position_ids
=
None
,
position_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
head_mask
=
None
,
head_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
torch
.
FloatTensor
]
=
None
,
start_positions
=
None
,
start_positions
:
Optional
[
torch
.
LongTensor
]
=
None
,
end_positions
=
None
,
end_positions
:
Optional
[
torch
.
LongTensor
]
=
None
,
output_attentions
=
None
,
output_attentions
:
Optional
[
bool
]
=
None
,
output_hidden_states
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
bbox
=
None
,
bbox
:
Optional
[
torch
.
LongTensor
]
=
None
,
pixel_values
=
None
,
pixel_values
:
Optional
[
torch
.
LongTensor
]
=
None
,
):
)
->
Union
[
Tuple
,
QuestionAnsweringModelOutput
]
:
r
"""
r
"""
start_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
start_positions (`torch.LongTensor` of shape `(batch_size,)`, *optional*):
Labels for position (index) of the start of the labelled span for computing the token classification loss.
Labels for position (index) of the start of the labelled span for computing the token classification loss.
...
@@ -1304,19 +1305,19 @@ class LayoutLMv3ForSequenceClassification(LayoutLMv3PreTrainedModel):
...
@@ -1304,19 +1305,19 @@ class LayoutLMv3ForSequenceClassification(LayoutLMv3PreTrainedModel):
@
replace_return_docstrings
(
output_type
=
SequenceClassifierOutput
,
config_class
=
_CONFIG_FOR_DOC
)
@
replace_return_docstrings
(
output_type
=
SequenceClassifierOutput
,
config_class
=
_CONFIG_FOR_DOC
)
def
forward
(
def
forward
(
self
,
self
,
input_ids
=
None
,
input_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
attention_mask
=
None
,
attention_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
token_type_ids
=
None
,
token_type_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
position_ids
=
None
,
position_ids
:
Optional
[
torch
.
LongTensor
]
=
None
,
head_mask
=
None
,
head_mask
:
Optional
[
torch
.
FloatTensor
]
=
None
,
inputs_embeds
=
None
,
inputs_embeds
:
Optional
[
torch
.
FloatTensor
]
=
None
,
labels
=
None
,
labels
:
Optional
[
torch
.
LongTensor
]
=
None
,
output_attentions
=
None
,
output_attentions
:
Optional
[
bool
]
=
None
,
output_hidden_states
=
None
,
output_hidden_states
:
Optional
[
bool
]
=
None
,
return_dict
=
None
,
return_dict
:
Optional
[
bool
]
=
None
,
bbox
=
None
,
bbox
:
Optional
[
torch
.
LongTensor
]
=
None
,
pixel_values
=
None
,
pixel_values
:
Optional
[
torch
.
LongTensor
]
=
None
,
):
)
->
Union
[
Tuple
,
SequenceClassifierOutput
]
:
"""
"""
Returns:
Returns:
...
...
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