broccoli-ml 0.1.38__tar.gz → 0.1.40__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/PKG-INFO +1 -1
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/broccoli/vit.py +32 -10
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/pyproject.toml +1 -1
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/LICENSE +0 -0
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/README.md +0 -0
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/broccoli/__init__.py +0 -0
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/broccoli/activation.py +0 -0
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/broccoli/assets/2025_resnet_imagenet_1k_pretrained_state_dict.pkl +0 -0
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/broccoli/assets/cifar100_eigenvectors_size_2.pt +0 -0
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/broccoli/assets/cifar100_eigenvectors_size_3.pt +0 -0
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/broccoli/cnn.py +0 -0
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/broccoli/eigenpatches.py +0 -0
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/broccoli/linear.py +0 -0
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/broccoli/rope.py +0 -0
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/broccoli/tensor.py +0 -0
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/broccoli/transformer.py +0 -0
- {broccoli_ml-0.1.38 → broccoli_ml-0.1.40}/broccoli/utils.py +0 -0
@@ -67,6 +67,7 @@ class CCTEncoder(nn.Module):
|
|
67
67
|
conv_pooling_kernel_size=3,
|
68
68
|
conv_pooling_kernel_stride=2,
|
69
69
|
conv_pooling_kernel_padding=1,
|
70
|
+
conv_dropout=0.0,
|
70
71
|
transformer_position_embedding="absolute", # absolute or relative
|
71
72
|
transformer_embedding_size=256,
|
72
73
|
transformer_layers=7,
|
@@ -155,15 +156,20 @@ class CCTEncoder(nn.Module):
|
|
155
156
|
)
|
156
157
|
|
157
158
|
elif conv_pooling_type == "concat":
|
158
|
-
concatpool_activation_output_channels = (
|
159
|
-
conv_pooling_kernel_size**2 * conv_out_channels
|
160
|
-
)
|
161
|
-
if cnn_activation.__name__.endswith("GLU"):
|
162
|
-
concatpool_activation_output_channels /= 2
|
163
159
|
|
164
|
-
|
165
|
-
|
166
|
-
|
160
|
+
if transformer_activation_kwargs is not None:
|
161
|
+
self.concatpool_activation = transformer_activation(
|
162
|
+
**transformer_activation_kwargs
|
163
|
+
)
|
164
|
+
else:
|
165
|
+
self.concatpool_activation = transformer_activation()
|
166
|
+
|
167
|
+
concatpool_out_channels = conv_pooling_kernel_size**2 * conv_out_channels
|
168
|
+
|
169
|
+
if cnn_activation.__name__.endswith("GLU"):
|
170
|
+
cnn_activation_output_channels = concatpool_out_channels / 2
|
171
|
+
else:
|
172
|
+
cnn_activation_output_channels = concatpool_out_channels
|
167
173
|
|
168
174
|
self.pool = nn.Sequential(
|
169
175
|
*[
|
@@ -176,8 +182,24 @@ class CCTEncoder(nn.Module):
|
|
176
182
|
"N C H W -> N H W C"
|
177
183
|
),
|
178
184
|
self.cnn_activation,
|
179
|
-
|
180
|
-
|
185
|
+
nn.Dropout(conv_dropout),
|
186
|
+
Rearrange( # rearrange in case we're using XGLU activation
|
187
|
+
"N H W C -> N C H W"
|
188
|
+
),
|
189
|
+
nn.BatchNorm2d(cnn_activation_output_channels),
|
190
|
+
Rearrange( # rearrange in case we're using XGLU activation
|
191
|
+
"N C H W -> N (H W) C"
|
192
|
+
),
|
193
|
+
nn.Linear(
|
194
|
+
cnn_activation_output_channels,
|
195
|
+
(
|
196
|
+
2 * transformer_embedding_size * transformer_mlp_ratio
|
197
|
+
if transformer_activation.__name__.endswith("GLU")
|
198
|
+
else transformer_embedding_size * transformer_mlp_ratio
|
199
|
+
),
|
200
|
+
),
|
201
|
+
self.concatpool_activation,
|
202
|
+
nn.Linear(transformer_embedding_size * transformer_mlp_ratio),
|
181
203
|
]
|
182
204
|
)
|
183
205
|
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|
File without changes
|