broccoli-ml 0.24.0__tar.gz → 0.24.1__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.24.0 → broccoli_ml-0.24.1}/PKG-INFO +1 -1
- {broccoli_ml-0.24.0 → broccoli_ml-0.24.1}/broccoli/activation.py +10 -8
- {broccoli_ml-0.24.0 → broccoli_ml-0.24.1}/pyproject.toml +1 -1
- {broccoli_ml-0.24.0 → broccoli_ml-0.24.1}/LICENSE +0 -0
- {broccoli_ml-0.24.0 → broccoli_ml-0.24.1}/README.md +0 -0
- {broccoli_ml-0.24.0 → broccoli_ml-0.24.1}/broccoli/__init__.py +0 -0
- {broccoli_ml-0.24.0 → broccoli_ml-0.24.1}/broccoli/assets/2025_resnet_imagenet_1k_pretrained_state_dict.pkl +0 -0
- {broccoli_ml-0.24.0 → broccoli_ml-0.24.1}/broccoli/assets/cifar100_eigenvectors_size_2.pt +0 -0
- {broccoli_ml-0.24.0 → broccoli_ml-0.24.1}/broccoli/assets/cifar100_eigenvectors_size_3.pt +0 -0
- {broccoli_ml-0.24.0 → broccoli_ml-0.24.1}/broccoli/cnn.py +0 -0
- {broccoli_ml-0.24.0 → broccoli_ml-0.24.1}/broccoli/eigenpatches.py +0 -0
- {broccoli_ml-0.24.0 → broccoli_ml-0.24.1}/broccoli/linear.py +0 -0
- {broccoli_ml-0.24.0 → broccoli_ml-0.24.1}/broccoli/rope.py +0 -0
- {broccoli_ml-0.24.0 → broccoli_ml-0.24.1}/broccoli/tensor.py +0 -0
- {broccoli_ml-0.24.0 → broccoli_ml-0.24.1}/broccoli/transformer.py +0 -0
- {broccoli_ml-0.24.0 → broccoli_ml-0.24.1}/broccoli/utils.py +0 -0
- {broccoli_ml-0.24.0 → broccoli_ml-0.24.1}/broccoli/vit.py +0 -0
@@ -8,16 +8,18 @@ class ReLU(nn.Module):
|
|
8
8
|
A ReLU activation function with optional clamp and leakiness.
|
9
9
|
"""
|
10
10
|
|
11
|
-
def __init__(
|
11
|
+
def __init__(
|
12
|
+
self, clamp=True, leaky=True, negative_slope=0.01, clamp_max=6.0
|
13
|
+
) -> None:
|
12
14
|
super().__init__()
|
13
15
|
self.clamp = clamp
|
14
16
|
self.leaky = leaky
|
15
|
-
self.
|
17
|
+
self.negative_slope = negative_slope
|
16
18
|
self.clamp_max = clamp_max
|
17
19
|
|
18
20
|
def forward(self, x):
|
19
21
|
if self.leaky:
|
20
|
-
relu = F.leaky_relu(x,
|
22
|
+
relu = F.leaky_relu(x, negative_slope=self.negative_slope)
|
21
23
|
else:
|
22
24
|
relu = F.relu(x)
|
23
25
|
if self.clamp:
|
@@ -69,17 +71,17 @@ class SquaredReLU(nn.Module):
|
|
69
71
|
"""
|
70
72
|
|
71
73
|
def __init__(
|
72
|
-
self, clamp=True, leaky=True,
|
74
|
+
self, clamp=True, leaky=True, negative_slope: float = 0.01, clamp_max=6
|
73
75
|
) -> None:
|
74
76
|
super().__init__()
|
75
77
|
self.clamp = clamp
|
76
78
|
self.leaky = leaky
|
77
|
-
self.
|
79
|
+
self.negative_slope = negative_slope
|
78
80
|
self.clamp_max = clamp_max
|
79
81
|
|
80
82
|
def forward(self, x):
|
81
83
|
if self.leaky:
|
82
|
-
relu = F.leaky_relu(x,
|
84
|
+
relu = F.leaky_relu(x, negative_slope=self.negative_slope)
|
83
85
|
else:
|
84
86
|
relu = F.relu(x)
|
85
87
|
relu_squared = relu**2
|
@@ -102,12 +104,12 @@ class XGLU(nn.Module):
|
|
102
104
|
return self.activation(gate) * value
|
103
105
|
|
104
106
|
|
105
|
-
def SquaredReGLU(clamp=True, leaky=True,
|
107
|
+
def SquaredReGLU(clamp=True, leaky=True, negative_slope=0.01, clamp_max=6.0) -> XGLU:
|
106
108
|
"""
|
107
109
|
Factory function that creates a GLU with a SquaredReLU activation.
|
108
110
|
"""
|
109
111
|
activation_module = SquaredReLU(
|
110
|
-
clamp=clamp, leaky=leaky,
|
112
|
+
clamp=clamp, leaky=leaky, negative_slope=negative_slope, clamp_max=clamp_max
|
111
113
|
)
|
112
114
|
return XGLU(activation_module)
|
113
115
|
|
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
|