Equimo 0.3.0__tar.gz → 0.3.2__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.
Files changed (38) hide show
  1. {equimo-0.3.0 → equimo-0.3.2}/Equimo.egg-info/PKG-INFO +2 -2
  2. {equimo-0.3.0 → equimo-0.3.2}/PKG-INFO +2 -2
  3. equimo-0.3.2/equimo/__init__.py +1 -0
  4. {equimo-0.3.0 → equimo-0.3.2}/equimo/layers/norm.py +54 -5
  5. {equimo-0.3.0 → equimo-0.3.2}/equimo/models/vit.py +6 -3
  6. {equimo-0.3.0 → equimo-0.3.2}/pyproject.toml +1 -1
  7. equimo-0.3.0/equimo/__init__.py +0 -1
  8. {equimo-0.3.0 → equimo-0.3.2}/Equimo.egg-info/SOURCES.txt +0 -0
  9. {equimo-0.3.0 → equimo-0.3.2}/Equimo.egg-info/dependency_links.txt +0 -0
  10. {equimo-0.3.0 → equimo-0.3.2}/Equimo.egg-info/requires.txt +0 -0
  11. {equimo-0.3.0 → equimo-0.3.2}/Equimo.egg-info/top_level.txt +0 -0
  12. {equimo-0.3.0 → equimo-0.3.2}/LICENSE.md +0 -0
  13. {equimo-0.3.0 → equimo-0.3.2}/README.md +0 -0
  14. {equimo-0.3.0 → equimo-0.3.2}/equimo/io.py +0 -0
  15. {equimo-0.3.0 → equimo-0.3.2}/equimo/layers/__init__.py +0 -0
  16. {equimo-0.3.0 → equimo-0.3.2}/equimo/layers/activation.py +0 -0
  17. {equimo-0.3.0 → equimo-0.3.2}/equimo/layers/attention.py +0 -0
  18. {equimo-0.3.0 → equimo-0.3.2}/equimo/layers/convolution.py +0 -0
  19. {equimo-0.3.0 → equimo-0.3.2}/equimo/layers/downsample.py +0 -0
  20. {equimo-0.3.0 → equimo-0.3.2}/equimo/layers/dropout.py +0 -0
  21. {equimo-0.3.0 → equimo-0.3.2}/equimo/layers/ffn.py +0 -0
  22. {equimo-0.3.0 → equimo-0.3.2}/equimo/layers/generic.py +0 -0
  23. {equimo-0.3.0 → equimo-0.3.2}/equimo/layers/mamba.py +0 -0
  24. {equimo-0.3.0 → equimo-0.3.2}/equimo/layers/patch.py +0 -0
  25. {equimo-0.3.0 → equimo-0.3.2}/equimo/layers/posemb.py +0 -0
  26. {equimo-0.3.0 → equimo-0.3.2}/equimo/layers/sharing.py +0 -0
  27. {equimo-0.3.0 → equimo-0.3.2}/equimo/layers/squeeze_excite.py +0 -0
  28. {equimo-0.3.0 → equimo-0.3.2}/equimo/models/__init__.py +0 -0
  29. {equimo-0.3.0 → equimo-0.3.2}/equimo/models/emamodel.py +0 -0
  30. {equimo-0.3.0 → equimo-0.3.2}/equimo/models/fastervit.py +0 -0
  31. {equimo-0.3.0 → equimo-0.3.2}/equimo/models/mlla.py +0 -0
  32. {equimo-0.3.0 → equimo-0.3.2}/equimo/models/partialformer.py +0 -0
  33. {equimo-0.3.0 → equimo-0.3.2}/equimo/models/shvit.py +0 -0
  34. {equimo-0.3.0 → equimo-0.3.2}/equimo/models/vssd.py +0 -0
  35. {equimo-0.3.0 → equimo-0.3.2}/equimo/ops/scan.py +0 -0
  36. {equimo-0.3.0 → equimo-0.3.2}/equimo/utils.py +0 -0
  37. {equimo-0.3.0 → equimo-0.3.2}/setup.cfg +0 -0
  38. {equimo-0.3.0 → equimo-0.3.2}/tests/test_models.py +0 -0
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: Equimo
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Implementation of popular vision models in Jax
5
5
  Classifier: Development Status :: 4 - Beta
6
6
  Classifier: Intended Audience :: Developers
@@ -1,6 +1,6 @@
1
- Metadata-Version: 2.2
1
+ Metadata-Version: 2.4
2
2
  Name: Equimo
3
- Version: 0.3.0
3
+ Version: 0.3.2
4
4
  Summary: Implementation of popular vision models in Jax
5
5
  Classifier: Development Status :: 4 - Beta
6
6
  Classifier: Intended Audience :: Developers
@@ -0,0 +1 @@
1
+ __version__ = "0.3.2"
@@ -31,6 +31,8 @@ class RMSNormGated(eqx.Module):
31
31
  self,
32
32
  x: Float[Array, "dim"],
33
33
  z: Optional[Float[Array, "dim"]] = None,
34
+ *args,
35
+ **kwargs,
34
36
  ) -> Float[Array, "dim"]:
35
37
  """Apply RMS normalization with optional gating.
36
38
 
@@ -58,12 +60,10 @@ class LayerScale(eqx.Module):
58
60
  dampening the contribution of each layer.
59
61
 
60
62
  Attributes:
61
- init_values: Initial scale value (static)
62
63
  gamma: Learnable scale parameters of size dim
63
64
  """
64
65
 
65
- init_values: float = eqx.field(static=True)
66
- gamma: Optional[Float[Array, "dim"]]
66
+ gamma: Float[Array, "dim"]
67
67
 
68
68
  def __init__(self, dim: int, init_values: float):
69
69
  """Initialize LayerScale.
@@ -72,8 +72,7 @@ class LayerScale(eqx.Module):
72
72
  dim: Dimension of the input features
73
73
  init_values: Initial value for all scaling factors
74
74
  """
75
- self.init_values = init_values
76
- self.gamma = jnp.repeat(self.init_values, dim)
75
+ self.gamma = jnp.repeat(init_values, dim)
77
76
 
78
77
  def __call__(self, x: Float[Array, "dim"]):
79
78
  """Apply layer scaling to input tensor.
@@ -87,6 +86,54 @@ class LayerScale(eqx.Module):
87
86
  return x * self.gamma
88
87
 
89
88
 
89
+ class DyT(eqx.Module):
90
+ """Dynamic Tanh layear.
91
+
92
+ This layer implements the DyT layer introduced in the Transformer
93
+ without Normalization paper[1].
94
+
95
+ Attributes:
96
+ init_values: Initial scale value (static)
97
+ gamma: Learnable scale parameters of size dim
98
+
99
+ References:
100
+ [1]. Zhu, et al., Transformers without Normalization. 2025.
101
+ https://arxiv.org/abs/2503.10622
102
+ """
103
+
104
+ alpha: Float[Array, "dim"]
105
+ weight: Float[Array, "dim"]
106
+ bias: Float[Array, "dim"]
107
+
108
+ def __init__(self, dim: int, alpha_init_value: float = 0.5):
109
+ """Initialize DyT.
110
+
111
+ Args:
112
+ dim: Dimension of the input features
113
+ alpha_init_value: Initial value for the scaling factor
114
+ """
115
+ self.alpha = jnp.repeat(alpha_init_value, dim)
116
+ self.weight = jnp.ones(dim)
117
+ self.bias = jnp.zeros(dim)
118
+
119
+ def __call__(
120
+ self,
121
+ x: Float[Array, "dim"],
122
+ *args,
123
+ **kwargs,
124
+ ):
125
+ """Apply dynamic tanh to input tensor.
126
+
127
+ Args:
128
+ x: Input tensor of shape (dim,)
129
+
130
+ Returns:
131
+ Scaled tensor of same shape as input
132
+ """
133
+ x = jnp.tanh(self.alpha * x)
134
+ return x * self.weight + self.bias
135
+
136
+
90
137
  def get_norm(module: str | eqx.Module) -> eqx.Module:
91
138
  """Get an `eqx.Module` from its common name.
92
139
 
@@ -107,5 +154,7 @@ def get_norm(module: str | eqx.Module) -> eqx.Module:
107
154
  return RMSNormGated
108
155
  case "layerscale":
109
156
  return LayerScale
157
+ case "dynamictanh":
158
+ return DyT
110
159
  case _:
111
160
  raise ValueError(f"Got an unknown module string: {module}")
@@ -403,6 +403,7 @@ class VisionTransformer(eqx.Module):
403
403
  key: PRNGKeyArray,
404
404
  mask: Optional[Int[Array, "embed_h embed_w"]] = None,
405
405
  inference: Optional[bool] = None,
406
+ **kwargs,
406
407
  ) -> Float[Array, "seqlen dim"]:
407
408
  """Extract features from input image.
408
409
 
@@ -434,7 +435,7 @@ class VisionTransformer(eqx.Module):
434
435
  x = self._pos_embed(x, h=self.embed_size, w=self.embed_size)
435
436
 
436
437
  for blk, key_block in zip(self.blocks, block_subkeys):
437
- x = blk(x, inference=inference, key=key_block)
438
+ x = blk(x, inference=inference, key=key_block, **kwargs)
438
439
 
439
440
  return x
440
441
 
@@ -443,6 +444,7 @@ class VisionTransformer(eqx.Module):
443
444
  x: Float[Array, "channels height width"],
444
445
  key: PRNGKeyArray,
445
446
  inference: Optional[bool] = None,
447
+ **kwargs,
446
448
  ) -> dict:
447
449
  """Process features and return intermediate representations.
448
450
 
@@ -458,7 +460,7 @@ class VisionTransformer(eqx.Module):
458
460
  - x_norm_patchtokens: Normalized patch tokens
459
461
  - x_prenorm: Pre-normalized features
460
462
  """
461
- x = self.features(x, inference=inference, key=key)
463
+ x = self.features(x, inference=inference, key=key, **kwargs)
462
464
  x_norm = jax.vmap(self.norm)(x)
463
465
 
464
466
  return {
@@ -473,6 +475,7 @@ class VisionTransformer(eqx.Module):
473
475
  x: Float[Array, "channels height width"],
474
476
  key: PRNGKeyArray = jr.PRNGKey(42),
475
477
  inference: Optional[bool] = None,
478
+ **kwargs,
476
479
  ) -> Float[Array, "num_classes"]:
477
480
  """Process input image through the full network.
478
481
 
@@ -484,7 +487,7 @@ class VisionTransformer(eqx.Module):
484
487
  Returns:
485
488
  Classification logits
486
489
  """
487
- x = self.features(x, inference=inference, key=key)
490
+ x = self.features(x, inference=inference, key=key, **kwargs)
488
491
  x = jax.vmap(self.norm)(x)
489
492
  x = pool_sd(
490
493
  x,
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "Equimo"
3
- version = "0.3.0"
3
+ version = "0.3.2"
4
4
  description = "Implementation of popular vision models in Jax"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.11"
@@ -1 +0,0 @@
1
- __version__ = "0.3.0"
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
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes