multilayer 0.0.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.
- multilayer/__init__.py +1 -0
- multilayer/build_normalization_layer.py +12 -0
- multilayer/enums/__init__.py +1 -0
- multilayer/enums/normalization_layers_enum.py +8 -0
- multilayer/mlp_function.py +33 -0
- multilayer-0.0.1.dist-info/METADATA +39 -0
- multilayer-0.0.1.dist-info/RECORD +10 -0
- multilayer-0.0.1.dist-info/WHEEL +5 -0
- multilayer-0.0.1.dist-info/licenses/LICENSE +21 -0
- multilayer-0.0.1.dist-info/top_level.txt +1 -0
multilayer/__init__.py
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .mlp_function import mlp
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import torch
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
def build_normalization_layer(
|
|
5
|
+
taxonomy: str, dimension: int, group_norm_division_factor: int
|
|
6
|
+
):
|
|
7
|
+
if taxonomy in {"layernorm", "layer"}:
|
|
8
|
+
return torch.nn.LayerNorm(dimension)
|
|
9
|
+
elif taxonomy in {"group", "groupnorm"}:
|
|
10
|
+
return torch.nn.GroupNorm(dimension // group_norm_division_factor, dimension)
|
|
11
|
+
else:
|
|
12
|
+
raise Exception("Invalid normalization layer passed.")
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
from .normalization_layers_enum import NormalizationLayersEnum
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import torch
|
|
2
|
+
from .build_normalization_layer import build_normalization_layer
|
|
3
|
+
from typing import Type
|
|
4
|
+
from multilayer.enums import NormalizationLayersEnum
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def mlp(
|
|
8
|
+
input_dimension: int,
|
|
9
|
+
output_dimension: int,
|
|
10
|
+
*hiddens: list[int],
|
|
11
|
+
activation: Type[torch.nn.Module] = torch.nn.GELU,
|
|
12
|
+
normalization_layer: NormalizationLayersEnum = "layernorm",
|
|
13
|
+
group_norm_division_factor: int = 8,
|
|
14
|
+
):
|
|
15
|
+
layers = [
|
|
16
|
+
torch.nn.Linear(input_dimension, hiddens[0], bias=False),
|
|
17
|
+
build_normalization_layer(
|
|
18
|
+
normalization_layer, hiddens[0], group_norm_division_factor
|
|
19
|
+
),
|
|
20
|
+
activation(),
|
|
21
|
+
]
|
|
22
|
+
for a, b in zip(hiddens[:-1], hiddens[1:]):
|
|
23
|
+
layers.extend(
|
|
24
|
+
[
|
|
25
|
+
torch.nn.Linear(a, b, bias=False),
|
|
26
|
+
build_normalization_layer(
|
|
27
|
+
normalization_layer, b, group_norm_division_factor
|
|
28
|
+
),
|
|
29
|
+
activation(),
|
|
30
|
+
]
|
|
31
|
+
)
|
|
32
|
+
layers.append(torch.nn.Linear(hiddens[-1], output_dimension))
|
|
33
|
+
return torch.nn.Sequential(*layers)
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: multilayer
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A very useful PyTorch helper for create laconic MLP layers.
|
|
5
|
+
Author-email: Taha Shieenavaz <tahashieenavaz@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/tahashieenavaz/multilayer
|
|
8
|
+
Project-URL: Repository, https://github.com/tahashieenavaz/multilayer
|
|
9
|
+
Project-URL: Documentation, https://github.com/tahashieenavaz/multilayer#readme
|
|
10
|
+
Project-URL: Issues, https://github.com/tahashieenavaz/multilayer/issues
|
|
11
|
+
Project-URL: Changelog, https://github.com/tahashieenavaz/multilayer/blob/main/CHANGELOG.md
|
|
12
|
+
Keywords: pytorch,multi layer perceptron,mlp,productive
|
|
13
|
+
Classifier: Development Status :: 4 - Beta
|
|
14
|
+
Classifier: Intended Audience :: Developers
|
|
15
|
+
Classifier: Operating System :: OS Independent
|
|
16
|
+
Classifier: Programming Language :: Python :: 3
|
|
17
|
+
Classifier: Programming Language :: Python :: 3 :: Only
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
19
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
20
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
21
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
22
|
+
Classifier: Programming Language :: Python :: 3.13
|
|
23
|
+
Classifier: Programming Language :: Python :: 3.14
|
|
24
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
25
|
+
Requires-Python: >=3.9
|
|
26
|
+
Description-Content-Type: text/markdown
|
|
27
|
+
License-File: LICENSE
|
|
28
|
+
Requires-Dist: torch
|
|
29
|
+
Provides-Extra: dev
|
|
30
|
+
Requires-Dist: build; extra == "dev"
|
|
31
|
+
Requires-Dist: pytest; extra == "dev"
|
|
32
|
+
Requires-Dist: pytest-cov; extra == "dev"
|
|
33
|
+
Requires-Dist: ruff; extra == "dev"
|
|
34
|
+
Requires-Dist: mypy; extra == "dev"
|
|
35
|
+
Requires-Dist: twine; extra == "dev"
|
|
36
|
+
Dynamic: license-file
|
|
37
|
+
|
|
38
|
+
# -multilayer
|
|
39
|
+
A very useful PyTorch helper for create laconic MLP layers
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
multilayer/__init__.py,sha256=ZvpIg7Wag1kJDaUQ_Kic8x-VVUF3n0C4L52yh8aJfu4,30
|
|
2
|
+
multilayer/build_normalization_layer.py,sha256=CXACxvrHngICsuKhl7zyURbCGHp45YfcOFH688C6H-0,408
|
|
3
|
+
multilayer/mlp_function.py,sha256=JaK00ij4O_FfVNBfzv9pBb0snUz-Sa2p48CuEF-ABg8,1063
|
|
4
|
+
multilayer/enums/__init__.py,sha256=4t7GgLGnvcS89ShqVmHoRBKLbTQ_ZB8NKRDSM8MM1FI,63
|
|
5
|
+
multilayer/enums/normalization_layers_enum.py,sha256=Jc0JVo2-cAgHkL-4XdJFFlMOoRBKxNZ0C6myhoVljs4,163
|
|
6
|
+
multilayer-0.0.1.dist-info/licenses/LICENSE,sha256=s-jnEPgz4FGpISRkyaeqzitRINkp57RfCyZu6p15syA,1072
|
|
7
|
+
multilayer-0.0.1.dist-info/METADATA,sha256=bVLyRtmgSPNEEbEjrbQiguUWEELgi4m0owgTOka0-lQ,1707
|
|
8
|
+
multilayer-0.0.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
|
|
9
|
+
multilayer-0.0.1.dist-info/top_level.txt,sha256=qixlBjQOrcNbrecj3sy1JgGiEGR5gUXBHy3cA2hdvrU,11
|
|
10
|
+
multilayer-0.0.1.dist-info/RECORD,,
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Taha Shieenavaz
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
multilayer
|