-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Make ViTPooler configurable #36517
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
Merged
Cyrilvallez
merged 31 commits into
huggingface:main
from
sebbaur:feature/vit_pooler_configurable
Mar 21, 2025
Merged
Make ViTPooler configurable #36517
Changes from all commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
97199e3
Make ViT Pooler configurable, so that it is possible to pick the acti…
sebbaur 43639fa
Add documentation and allow functions as activations (instead of just…
sebbaur 80e132a
formatting change
sebbaur 9fe0691
Use ACT2FN
sebbaur bd2a001
Formatting change
sebbaur 18edafb
Formatting changes
sebbaur 5060f56
force pooler_act to be string
sebbaur 0a2895f
force pooler_act to be string
sebbaur 9e9dfd1
Add configs to OBJECTS_TO_IGNORE to make check_docstrings happy
sebbaur 0d2b485
Making the same change in ijepa to make check_modular_conversion happy
sebbaur e0d6928
Add IJepaConfig to make CI happy
sebbaur 0881e5f
rename pooler_size to pooler_output_size as defined in the config
sebbaur e2670cc
typo
sebbaur 0382960
Merge branch 'main' into feature/vit_pooler_configurable
sebbaur c89f69b
revert change to ignore variable
sebbaur 6309d96
Merge branch 'feature/vit_pooler_configurable' of https://github.com/…
sebbaur 6c6a1ac
Merge branch 'main' into feature/vit_pooler_configurable
sebbaur 5ffac41
Merge branch 'main' into feature/vit_pooler_configurable
sebbaur ad2aeca
Ran utils/check_docstrings.py --fix_and_overwrite
sebbaur bc5ef1b
revert unrelated change
sebbaur 2d0071f
remove redundant defaults
sebbaur 3ca67c1
rename self.act -> self.activation
sebbaur 05499eb
Merge branch 'main' into feature/vit_pooler_configurable
sebbaur ab56b63
Merge branch 'main' into feature/vit_pooler_configurable
sebbaur 308b5b3
Merge branch 'main' into feature/vit_pooler_configurable
sebbaur 7e9bc63
Merge branch 'main' into feature/vit_pooler_configurable
sebbaur eff0bd1
Merge branch 'main' into feature/vit_pooler_configurable
sebbaur 8028f62
Merge branch 'main' into feature/vit_pooler_configurable
sebbaur 87b9162
tanh activation function in mapping
sebbaur 16dfb96
Merge branch 'feature/vit_pooler_configurable' of https://github.com/…
sebbaur 366edfe
Merge branch 'main' into feature/vit_pooler_configurable
sebbaur File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -412,17 +412,18 @@ class FlaxViTPooler(nn.Module): | |
|
|
||
| def setup(self): | ||
| self.dense = nn.Dense( | ||
| self.config.hidden_size, | ||
| self.config.pooler_output_size, | ||
| kernel_init=jax.nn.initializers.variance_scaling( | ||
| self.config.initializer_range**2, "fan_in", "truncated_normal" | ||
| ), | ||
| dtype=self.dtype, | ||
| ) | ||
| self.activation = ACT2FN[self.config.pooler_act] | ||
|
Comment on lines
420
to
+421
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
|
||
|
|
||
| def __call__(self, hidden_states): | ||
| cls_hidden_state = hidden_states[:, 0] | ||
| cls_hidden_state = self.dense(cls_hidden_state) | ||
| return nn.tanh(cls_hidden_state) | ||
| return self.activation(cls_hidden_state) | ||
|
|
||
|
|
||
| class FlaxViTPreTrainedModel(FlaxPreTrainedModel): | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.