Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[ViTMAE] Renamed variable name #18850

Merged
merged 2 commits into from
Oct 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/transformers/models/vit_mae/modeling_tf_vit_mae.py
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ def random_masking(self, sequence: tf.Tensor, noise: Optional[tf.Tensor] = None)

# keep the first subset
ids_keep = ids_shuffle[:, :len_keep]
sequence_masked = tf.gather(
sequence_unmasked = tf.gather(
sequence,
axis=1,
batch_dims=1,
Expand All @@ -271,7 +271,7 @@ def random_masking(self, sequence: tf.Tensor, noise: Optional[tf.Tensor] = None)
# unshuffle to get the binary mask
mask = tf.gather(mask, axis=1, batch_dims=1, indices=ids_restore)

return sequence_masked, mask, ids_restore
return sequence_unmasked, mask, ids_restore

def call(self, pixel_values: tf.Tensor, noise: tf.Tensor = None) -> tf.Tensor:
embeddings = self.patch_embeddings(pixel_values)
Expand Down
4 changes: 2 additions & 2 deletions src/transformers/models/vit_mae/modeling_vit_mae.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,15 @@ def random_masking(self, sequence, noise=None):

# keep the first subset
ids_keep = ids_shuffle[:, :len_keep]
sequence_masked = torch.gather(sequence, dim=1, index=ids_keep.unsqueeze(-1).repeat(1, 1, dim))
sequence_unmasked = torch.gather(sequence, dim=1, index=ids_keep.unsqueeze(-1).repeat(1, 1, dim))

# generate the binary mask: 0 is keep, 1 is remove
mask = torch.ones([batch_size, seq_length], device=sequence.device)
mask[:, :len_keep] = 0
# unshuffle to get the binary mask
mask = torch.gather(mask, dim=1, index=ids_restore)

return sequence_masked, mask, ids_restore
return sequence_unmasked, mask, ids_restore

def forward(self, pixel_values, noise=None):
batch_size, num_channels, height, width = pixel_values.shape
Expand Down