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
011cc17a
Unverified
Commit
011cc17a
authored
Feb 20, 2023
by
Morgan McGuire
Committed by
GitHub
Feb 20, 2023
Browse files
Fix for non-contiguous label tensors in VisonEncoderDecoder (#21582)
* add prints * add shape * add reshape * clean up
parent
2840272c
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
1 addition
and
1 deletion
+1
-1
src/transformers/models/vision_encoder_decoder/modeling_vision_encoder_decoder.py
...vision_encoder_decoder/modeling_vision_encoder_decoder.py
+1
-1
No files found.
src/transformers/models/vision_encoder_decoder/modeling_vision_encoder_decoder.py
View file @
011cc17a
...
...
@@ -625,7 +625,7 @@ class VisionEncoderDecoderModel(PreTrainedModel):
if
labels
is
not
None
:
logits
=
decoder_outputs
.
logits
if
return_dict
else
decoder_outputs
[
0
]
loss_fct
=
CrossEntropyLoss
()
loss
=
loss_fct
(
logits
.
reshape
(
-
1
,
self
.
decoder
.
config
.
vocab_size
),
labels
.
view
(
-
1
))
loss
=
loss_fct
(
logits
.
reshape
(
-
1
,
self
.
decoder
.
config
.
vocab_size
),
labels
.
reshape
(
-
1
))
if
not
return_dict
:
if
loss
is
not
None
:
...
...
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