jaxonlayers 0.2.4__tar.gz → 0.2.5__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 (36) hide show
  1. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/PKG-INFO +1 -1
  2. jaxonlayers-0.2.5/jaxonlayers/layers/embedding.py +56 -0
  3. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/pyproject.toml +1 -1
  4. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/.gitignore +0 -0
  5. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/.pre-commit-config.yaml +0 -0
  6. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/.python-version +0 -0
  7. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/README.md +0 -0
  8. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/__init__.py +0 -0
  9. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/functions/__init__.py +0 -0
  10. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/functions/activation.py +0 -0
  11. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/functions/attention.py +0 -0
  12. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/functions/embedding.py +0 -0
  13. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/functions/initialization.py +0 -0
  14. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/functions/masking.py +0 -0
  15. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/functions/normalization.py +0 -0
  16. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/functions/regularization.py +0 -0
  17. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/functions/state_space.py +0 -0
  18. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/functions/utils.py +0 -0
  19. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/layers/__init__.py +0 -0
  20. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/layers/abstract.py +0 -0
  21. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/layers/attention.py +0 -0
  22. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/layers/convolution.py +0 -0
  23. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/layers/normalization.py +0 -0
  24. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/layers/regularization.py +0 -0
  25. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/layers/sequential.py +0 -0
  26. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/layers/state_space.py +0 -0
  27. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/jaxonlayers/layers/transformer.py +0 -0
  28. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/tests/__init__.py +0 -0
  29. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/tests/test_attention.py +0 -0
  30. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/tests/test_batch_norm.py +0 -0
  31. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/tests/test_efficientnet_layers.py +0 -0
  32. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/tests/test_layernorm.py +0 -0
  33. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/tests/test_local_response_normalisation.py +0 -0
  34. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/tests/test_mha.py +0 -0
  35. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/tests/test_transformer.py +0 -0
  36. {jaxonlayers-0.2.4 → jaxonlayers-0.2.5}/uv.lock +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: jaxonlayers
3
- Version: 0.2.4
3
+ Version: 0.2.5
4
4
  Summary: Additional layers and functions that extend Equinox
5
5
  Requires-Python: >=3.13
6
6
  Requires-Dist: beartype>=0.21.0
@@ -0,0 +1,56 @@
1
+ import equinox as eqx
2
+ from beartype.typing import Any
3
+ from jaxtyping import Array, PRNGKeyArray
4
+
5
+ from jaxonlayers.functions import default_floating_dtype
6
+
7
+
8
+ class EmbeddingWithPadding(eqx.Module):
9
+ embed: eqx.nn.Embedding
10
+ padding_idx: int = eqx.field(static=True)
11
+
12
+ def __init__(
13
+ self,
14
+ num_embeddings: int,
15
+ embedding_dim: int,
16
+ padding_idx: int = 0,
17
+ *,
18
+ key: PRNGKeyArray,
19
+ dtype: Any | None = None,
20
+ ):
21
+ if dtype is None:
22
+ dtype = default_floating_dtype()
23
+ assert dtype is not None
24
+ self.embed = eqx.nn.Embedding(
25
+ num_embeddings, embedding_dim, key=key, dtype=dtype
26
+ )
27
+ self.padding_idx = padding_idx
28
+
29
+ def __call__(self, x: Array):
30
+ out = self.embed(x)
31
+ mask = (x != self.padding_idx).astype(out.dtype)
32
+ return out * mask[..., None]
33
+
34
+
35
+ class EmbeddingBag(eqx.Module):
36
+ embed: EmbeddingWithPadding
37
+
38
+ def __init__(
39
+ self,
40
+ num_embeddings: int,
41
+ embedding_dim: int,
42
+ padding_idx: int = 0,
43
+ *,
44
+ key: PRNGKeyArray,
45
+ dtype: Any | None = None,
46
+ ):
47
+ if dtype is None:
48
+ dtype = default_floating_dtype()
49
+ assert dtype is not None
50
+ self.embed = EmbeddingWithPadding(
51
+ num_embeddings, embedding_dim, padding_idx=padding_idx, key=key, dtype=dtype
52
+ )
53
+
54
+ def __call__(self, x):
55
+ looked_up = eqx.filter_vmap(self.embed)(x)
56
+ return looked_up.sum(axis=0)
@@ -1,6 +1,6 @@
1
1
  [project]
2
2
  name = "jaxonlayers"
3
- version = "0.2.4"
3
+ version = "0.2.5"
4
4
  description = "Additional layers and functions that extend Equinox"
5
5
  readme = "README.md"
6
6
  requires-python = ">=3.13"
File without changes
File without changes
File without changes
File without changes