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
8714b964
Unverified
Commit
8714b964
authored
May 31, 2023
by
amyeroberts
Committed by
GitHub
May 31, 2023
Browse files
Raise error if loss can't be calculated - ViT MIM (#23872)
Raise error if loss can't be calculated
parent
404d9253
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
7 additions
and
0 deletions
+7
-0
src/transformers/models/vit/modeling_vit.py
src/transformers/models/vit/modeling_vit.py
+7
-0
No files found.
src/transformers/models/vit/modeling_vit.py
View file @
8714b964
...
@@ -695,6 +695,13 @@ class ViTForMaskedImageModeling(ViTPreTrainedModel):
...
@@ -695,6 +695,13 @@ class ViTForMaskedImageModeling(ViTPreTrainedModel):
```"""
```"""
return_dict
=
return_dict
if
return_dict
is
not
None
else
self
.
config
.
use_return_dict
return_dict
=
return_dict
if
return_dict
is
not
None
else
self
.
config
.
use_return_dict
if
bool_masked_pos
is
not
None
and
(
self
.
config
.
patch_size
!=
self
.
config
.
encoder_stride
):
raise
ValueError
(
"When `bool_masked_pos` is provided, `patch_size` must be equal to `encoder_stride` to ensure that "
"the reconstructed image has the same dimensions as the input."
f
"Got `patch_size` =
{
self
.
config
.
patch_size
}
and `encoder_stride` =
{
self
.
config
.
encoder_stride
}
."
)
outputs
=
self
.
vit
(
outputs
=
self
.
vit
(
pixel_values
,
pixel_values
,
bool_masked_pos
=
bool_masked_pos
,
bool_masked_pos
=
bool_masked_pos
,
...
...
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