configuration_ijepa.py 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. # Copyright 2024 The HuggingFace Inc. team. All rights reserved.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License");
  4. # you may not use this file except in compliance with the License.
  5. # You may obtain a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS,
  11. # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. # See the License for the specific language governing permissions and
  13. # limitations under the License.
  14. """I-JEPA model configuration"""
  15. from huggingface_hub.dataclasses import strict
  16. from ...configuration_utils import PreTrainedConfig
  17. from ...utils import auto_docstring
  18. @auto_docstring(checkpoint="facebook/ijepa_vith14_1k")
  19. @strict
  20. class IJepaConfig(PreTrainedConfig):
  21. r"""
  22. pooler_output_size (`int`, *optional*):
  23. Dimensionality of the pooler layer. If None, defaults to `hidden_size`.
  24. pooler_act (`str`, *optional*, defaults to `"tanh"`):
  25. The activation function to be used by the pooler.
  26. Example:
  27. ```python
  28. >>> from transformers import IJepaConfig, IJepaModel
  29. >>> # Initializing a IJEPA ijepa-base-patch16-224 style configuration
  30. >>> configuration = IJepaConfig()
  31. >>> # Initializing a model (with random weights) from the ijepa-base-patch16-224 style configuration
  32. >>> model = IJepaModel(configuration)
  33. >>> # Accessing the model configuration
  34. >>> configuration = model.config
  35. ```"""
  36. model_type = "ijepa"
  37. hidden_size: int = 768
  38. num_hidden_layers: int = 12
  39. num_attention_heads: int = 12
  40. intermediate_size: int = 3072
  41. hidden_act: str = "gelu"
  42. hidden_dropout_prob: float | int = 0.0
  43. attention_probs_dropout_prob: float | int = 0.0
  44. initializer_range: float = 0.02
  45. layer_norm_eps: float = 1e-12
  46. image_size: int | list[int] | tuple[int, int] = 224
  47. patch_size: int | list[int] | tuple[int, int] = 16
  48. num_channels: int = 3
  49. qkv_bias: bool = True
  50. pooler_output_size: int | None = None
  51. pooler_act: str = "tanh"
  52. def __post_init__(self, **kwargs):
  53. self.pooler_output_size = self.pooler_output_size if self.pooler_output_size else self.hidden_size
  54. super().__post_init__(**kwargs)
  55. __all__ = ["IJepaConfig"]