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
8a817e1e
"templates/vscode:/vscode.git/clone" did not exist on "b2b7fc781438c7d1d551cdac0a44af5ca0399797"
Unverified
Commit
8a817e1e
authored
Apr 21, 2023
by
SUSHMANTH REDDY
Committed by
GitHub
Apr 20, 2023
Browse files
moved labels to the same device as logits for LILT model (#22898)
parent
515d6a55
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
4 additions
and
0 deletions
+4
-0
src/transformers/models/lilt/modeling_lilt.py
src/transformers/models/lilt/modeling_lilt.py
+4
-0
No files found.
src/transformers/models/lilt/modeling_lilt.py
View file @
8a817e1e
...
...
@@ -924,6 +924,8 @@ class LiltForSequenceClassification(LiltPreTrainedModel):
loss
=
None
if
labels
is
not
None
:
# move labels to correct device to enable model parallelism
labels
=
labels
.
to
(
logits
.
device
)
if
self
.
config
.
problem_type
is
None
:
if
self
.
num_labels
==
1
:
self
.
config
.
problem_type
=
"regression"
...
...
@@ -1046,6 +1048,8 @@ class LiltForTokenClassification(LiltPreTrainedModel):
loss
=
None
if
labels
is
not
None
:
# move labels to correct device to enable model parallelism
labels
=
labels
.
to
(
logits
.
device
)
loss_fct
=
CrossEntropyLoss
()
loss
=
loss_fct
(
logits
.
view
(
-
1
,
self
.
num_labels
),
labels
.
view
(
-
1
))
...
...
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