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
0a3d0e02
"...git@developer.sourcefind.cn:wangsen/paddle_dbnet.git" did not exist on "2945abd703ee83fff02fbcad4806a506289e0105"
Unverified
Commit
0a3d0e02
authored
Jun 24, 2020
by
Setu Shah
Committed by
GitHub
Jun 24, 2020
Browse files
Replace labels with -100 to skip loss calc (#4718)
parent
6894b486
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
1 deletion
+3
-1
src/transformers/data/data_collator.py
src/transformers/data/data_collator.py
+3
-1
No files found.
src/transformers/data/data_collator.py
View file @
0a3d0e02
...
@@ -82,7 +82,9 @@ class DataCollatorForLanguageModeling:
...
@@ -82,7 +82,9 @@ class DataCollatorForLanguageModeling:
inputs
,
labels
=
self
.
mask_tokens
(
batch
)
inputs
,
labels
=
self
.
mask_tokens
(
batch
)
return
{
"input_ids"
:
inputs
,
"labels"
:
labels
}
return
{
"input_ids"
:
inputs
,
"labels"
:
labels
}
else
:
else
:
return
{
"input_ids"
:
batch
,
"labels"
:
batch
}
labels
=
batch
.
clone
().
detach
()
labels
[
labels
==
self
.
tokenizer
.
pad_token_id
]
=
-
100
return
{
"input_ids"
:
batch
,
"labels"
:
labels
}
def
_tensorize_batch
(
self
,
examples
:
List
[
torch
.
Tensor
])
->
torch
.
Tensor
:
def
_tensorize_batch
(
self
,
examples
:
List
[
torch
.
Tensor
])
->
torch
.
Tensor
:
length_of_first
=
examples
[
0
].
size
(
0
)
length_of_first
=
examples
[
0
].
size
(
0
)
...
...
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