broccoli-ml 0.27.0__tar.gz → 0.29.0__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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: broccoli-ml
3
- Version: 0.27.0
3
+ Version: 0.29.0
4
4
  Summary: Some useful Pytorch models, circa 2025
5
5
  License: MIT
6
6
  Author: Nicholas Bailey
@@ -95,7 +95,7 @@ class AnchoredLinear(nn.Module):
95
95
  )
96
96
 
97
97
 
98
- class ReparamLinear(nn.Module):
98
+ class WeightNormedLinear(nn.Module):
99
99
  """
100
100
  ...
101
101
  """
@@ -10,7 +10,7 @@ import torch.nn.functional as F
10
10
  from einops import rearrange
11
11
 
12
12
  from .rope import RotaryEmbedding, apply_rotary_emb
13
- from .linear import AnchoredLinear
13
+ from .linear import AnchoredLinear, SpectralNormLinear
14
14
 
15
15
 
16
16
  class MHAttention(nn.Module):
@@ -238,6 +238,7 @@ class FeedforwardBlock(nn.Module):
238
238
  linear_module=nn.Linear,
239
239
  pre_norm=True,
240
240
  normformer=False,
241
+ raw_input=False,
241
242
  ):
242
243
  super().__init__()
243
244
 
@@ -246,6 +247,11 @@ class FeedforwardBlock(nn.Module):
246
247
  else:
247
248
  self.activation = activation()
248
249
 
250
+ if raw_input:
251
+ self.memory_type = SpectralNormLinear
252
+ else:
253
+ self.memory_type = nn.Linear
254
+
249
255
  self.dropout = nn.Dropout(dropout)
250
256
 
251
257
  self.max_features = (
@@ -260,7 +266,7 @@ class FeedforwardBlock(nn.Module):
260
266
  linear_module(input_features, self.max_features),
261
267
  self.activation,
262
268
  nn.LayerNorm(ratio * output_features) if normformer else nn.Identity(),
263
- linear_module(ratio * output_features, output_features),
269
+ self.memory_type(ratio * output_features, output_features),
264
270
  self.dropout,
265
271
  ]
266
272
  )
@@ -308,6 +308,7 @@ class ViTEncoder(nn.Module):
308
308
  linear_module=linear_module,
309
309
  pre_norm=transformer_pre_norm,
310
310
  normformer=transformer_normformer,
311
+ raw_input=not cnn,
311
312
  )
312
313
  else:
313
314
  self.initial_ff = nn.Identity()
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "broccoli-ml"
3
- version = "0.27.0"
3
+ version = "0.29.0"
4
4
  description = "Some useful Pytorch models, circa 2025"
5
5
  authors = [
6
6
  {name = "Nicholas Bailey"}
File without changes
File without changes