Update configuration_eat.py
Browse files- configuration_eat.py +67 -58
configuration_eat.py
CHANGED
|
@@ -1,58 +1,67 @@
|
|
| 1 |
-
|
| 2 |
-
|
| 3 |
-
|
| 4 |
-
|
| 5 |
-
|
| 6 |
-
|
| 7 |
-
|
| 8 |
-
|
| 9 |
-
|
| 10 |
-
|
| 11 |
-
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
|
| 22 |
-
|
| 23 |
-
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
self.
|
| 43 |
-
self.
|
| 44 |
-
self.
|
| 45 |
-
|
| 46 |
-
self.
|
| 47 |
-
self.
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
self.
|
| 51 |
-
self.
|
| 52 |
-
self.
|
| 53 |
-
self.
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
self.
|
| 57 |
-
self.
|
| 58 |
-
self.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
from transformers import PretrainedConfig
|
| 2 |
+
|
| 3 |
+
class EATConfig(PretrainedConfig):
|
| 4 |
+
model_type = "eat"
|
| 5 |
+
|
| 6 |
+
def __init__(
|
| 7 |
+
self,
|
| 8 |
+
# --- 1. Core Architecture (Dimensions) ---
|
| 9 |
+
embed_dim=768,
|
| 10 |
+
depth=12,
|
| 11 |
+
num_heads=12,
|
| 12 |
+
mlp_ratio=4.0,
|
| 13 |
+
num_classes=527,
|
| 14 |
+
model_variant="pretrain", # or "finetune"
|
| 15 |
+
|
| 16 |
+
# --- 2. Input & Patching ---
|
| 17 |
+
in_chans=1,
|
| 18 |
+
patch_size=16,
|
| 19 |
+
stride=16,
|
| 20 |
+
fixed_positions=True,
|
| 21 |
+
|
| 22 |
+
# --- 3. Normalization & Bias Structure ---
|
| 23 |
+
qkv_bias=True,
|
| 24 |
+
layer_norm_first=False,
|
| 25 |
+
norm_affine=True,
|
| 26 |
+
norm_eps=1e-6,
|
| 27 |
+
|
| 28 |
+
# --- 4. Fine-Tuning Knobs (Regularization) ---
|
| 29 |
+
drop_rate=0.0,
|
| 30 |
+
attn_drop_rate=0.0,
|
| 31 |
+
activation_dropout=0.0,
|
| 32 |
+
post_mlp_drop=0.0,
|
| 33 |
+
start_drop_path_rate=0.0,
|
| 34 |
+
end_drop_path_rate=0.0,
|
| 35 |
+
|
| 36 |
+
# --- 5. Hugging Face Extras ---
|
| 37 |
+
**kwargs,
|
| 38 |
+
):
|
| 39 |
+
super().__init__(**kwargs)
|
| 40 |
+
|
| 41 |
+
# --- 1. Core Architecture ---
|
| 42 |
+
self.embed_dim = embed_dim
|
| 43 |
+
self.depth = depth
|
| 44 |
+
self.num_heads = num_heads
|
| 45 |
+
self.mlp_ratio = mlp_ratio
|
| 46 |
+
self.num_classes = num_classes
|
| 47 |
+
self.model_variant = model_variant
|
| 48 |
+
|
| 49 |
+
# --- 2. Input & Patching ---
|
| 50 |
+
self.in_chans = in_chans
|
| 51 |
+
self.patch_size = patch_size
|
| 52 |
+
self.stride = stride
|
| 53 |
+
self.fixed_positions = fixed_positions
|
| 54 |
+
|
| 55 |
+
# --- 3. Normalization & Bias ---
|
| 56 |
+
self.qkv_bias = qkv_bias
|
| 57 |
+
self.layer_norm_first = layer_norm_first
|
| 58 |
+
self.norm_affine = norm_affine
|
| 59 |
+
self.norm_eps = norm_eps
|
| 60 |
+
|
| 61 |
+
# --- 4. Regularization ---
|
| 62 |
+
self.drop_rate = drop_rate
|
| 63 |
+
self.attn_drop_rate = attn_drop_rate
|
| 64 |
+
self.activation_dropout = activation_dropout
|
| 65 |
+
self.post_mlp_drop = post_mlp_drop
|
| 66 |
+
self.start_drop_path_rate = start_drop_path_rate
|
| 67 |
+
self.end_drop_path_rate = end_drop_path_rate
|