Unverified Commit 8714b964 authored by amyeroberts's avatar amyeroberts Committed by GitHub
Browse files

Raise error if loss can't be calculated - ViT MIM (#23872)

Raise error if loss can't be calculated
parent 404d9253
......@@ -695,6 +695,13 @@ class ViTForMaskedImageModeling(ViTPreTrainedModel):
```"""
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(
pixel_values,
bool_masked_pos=bool_masked_pos,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment