broccoli-ml 10.0.1__py3-none-any.whl → 10.1.1__py3-none-any.whl

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/transformer.py CHANGED
@@ -710,6 +710,11 @@ class TransformerEncoder(nn.Module):
710
710
  self._utility_tokens = utility_tokens
711
711
  self.return_utility_tokens = return_utility_tokens
712
712
 
713
+ if layerscale:
714
+ self.layerscale = LayerScale(d_model)
715
+ else:
716
+ self.layerscale = None
717
+
713
718
  # Initialise utility tokens with normal init, like usual Pytorch embeddings
714
719
  if self._utility_tokens:
715
720
  self._utility_token_embedding = nn.Parameter(
@@ -795,13 +800,16 @@ class TransformerEncoder(nn.Module):
795
800
  x = x
796
801
 
797
802
  if self.absolute_position_embedding is not None:
798
- x = x + self.absolute_position_embedding(
803
+ position_embedding = self.absolute_position_embedding(
799
804
  torch.arange(
800
805
  0, self.full_sequence_length, dtype=torch.long, device=x.device
801
806
  ).unsqueeze(
802
807
  0
803
808
  ) # to shape (1, seq_len) to broadcast over batch
804
809
  )
810
+ if self.layerscale is not None:
811
+ position_embedding = self.layerscale(position_embedding)
812
+ x += position_embedding
805
813
 
806
814
  return x
807
815
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: broccoli-ml
3
- Version: 10.0.1
3
+ Version: 10.1.1
4
4
  Summary: Some useful Pytorch models, circa 2025
5
5
  License: MIT
6
6
  Author: Nicholas Bailey
@@ -4,10 +4,10 @@ broccoli/cnn.py,sha256=WjoPDSpe3ttwxCBNfCVRdaCHvbeZ7G-a5_i8fUsK_d8,4889
4
4
  broccoli/linear.py,sha256=W-3aNpBjd_0xRyzbCKkmg4H1qmslQOIQhB-WDDay2nM,13125
5
5
  broccoli/rope.py,sha256=GRqApBNmYCFaDak0WL1xE_BC5CTTYKQU_PBdeTcQcjc,12557
6
6
  broccoli/tensor.py,sha256=um8mrxkYbvNDo-QvHlmJm8Aw6qcngOlUZPoAk_PMReA,4480
7
- broccoli/transformer.py,sha256=lnfiv7UIYbABiClIluy6CefGxaiYMrvBcj2Ul0uU6xE,27693
7
+ broccoli/transformer.py,sha256=a2l1uRWr6wD6Q84XdYmTsimNqBxDDmbK719b6fwKCik,27982
8
8
  broccoli/utils.py,sha256=oOWzn6dJ5nC_9r4zq0emmfmaYACJXJNFS48AOpW2jqc,358
9
9
  broccoli/vit.py,sha256=EGbQb-atuzG3JAx7kdTaJEbWvQR-4XgyYvwjKkN5C38,22612
10
- broccoli_ml-10.0.1.dist-info/LICENSE,sha256=0BAzJE5BqQ7Iixp_AFdB2W1uO-HCRX-Qfun8PHt6yVM,1073
11
- broccoli_ml-10.0.1.dist-info/METADATA,sha256=65GKe2Jor5jgUZ8zxROntJ_t0XwAlaukrvpT7nxS0lQ,1369
12
- broccoli_ml-10.0.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
13
- broccoli_ml-10.0.1.dist-info/RECORD,,
10
+ broccoli_ml-10.1.1.dist-info/LICENSE,sha256=0BAzJE5BqQ7Iixp_AFdB2W1uO-HCRX-Qfun8PHt6yVM,1073
11
+ broccoli_ml-10.1.1.dist-info/METADATA,sha256=fi_mTSGNka5gnIfIVuvaunXqzbppH7NXMZR4ierpVbY,1369
12
+ broccoli_ml-10.1.1.dist-info/WHEEL,sha256=b4K_helf-jlQoXBBETfwnf4B04YC67LOev0jo4fX5m8,88
13
+ broccoli_ml-10.1.1.dist-info/RECORD,,