Neural Network Pipeline that helps you to build intricate network more easy way.
Project description
Neural Network Pipeline
Simple network building pipeline for PyTorch. (torch>=2.1,<2.2)
How to start?
-
install
pip install fish-nnpipelineandimport nnpipeline -
create a pipe base object. (ex: `layer = nnpipeline.LinearExponentialEncoder(10, 5))
-
chain it to
torch.nn.sequentialor do whatever you want. all pipeline object followstorch.nn.Module.. (at leastforwardmethod exists.)
Explain of each pipeline object
- Layers
1.1. LinearExponentialEncoder : Generate linear layers semi-automatically. You should give in_features, out_features and the class do the rest.
You can control narrowing node ratio by compression_rate parameter. (default 0.618) Also can use noramlization, dropout.
You cannot alter order between linear and others like norm, activation, dropout. It has been fixed (linear -> norm -> activation -> dropout) because I'm super lazy.
lee = LinearExponentialEncoder(100, 34)
# what lee is..
LinearExponentialEncoder(
(layers): Sequential(
(0): Linear(in_features=100, out_features=61, bias=True)
(1): BatchNorm1d(61, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU()
(3): Linear(in_features=61, out_features=37, bias=True)
(4): BatchNorm1d(37, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(5): ReLU()
(6): Linear(in_features=37, out_features=34, bias=True)
(7): BatchNorm1d(34, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(8): ReLU()
)
)
1.2. LinearExponentialDecoder : Encoder is narrowing down linear nodes. Decoder is expanding nodes. It's like a mirror of encoder.
Those linear encoder/decoder work based on exponentially inceasing/decreasing sequence that start from in_features to out_features. As you can see above example of lee, it works just like normal torch.nn.Module object. So you can put this in nn.Sequential or something.
1.3. LinearCylinder : Cylinder is a simple multi-layer module that has same input, output features. It looks just like a cylinder so the name is also cylinder.
- Glues
2.1. LinearJoint LYou can concatenate multiple pipeline output to one single pipeline using torch.cat. yes you can do this by yourself, but I prefer this way more.
- Compositions
3.1. LinearExponentialComposition: You can direcly use multiple pipes and join them manually, or you can simply define COMPOSITION class.
l1 = LinearExponentialEncoder(100, 35)
l2 = LinearExponentialEncoder(150, 40)
l3 = LinearExponentialEncoder(120, 30)
lec = LinearExponentialComposition([l1, l2, l3], 80)
print(lec)
# I'm lec!
LinearExponentialComposition(
(pipes): ModuleList(
(0): LinearExponentialEncoder(
(layers): Sequential(
(0): Linear(in_features=100, out_features=61, bias=True)
...
(8): ReLU()
)
)
(1): LinearExponentialEncoder(
(layers): Sequential(
(0): Linear(in_features=150, out_features=92, bias=True)
...
(8): ReLU()
)
)
(2): LinearExponentialEncoder(
(layers): Sequential(
(0): Linear(in_features=120, out_features=74, bias=True)
...
(8): ReLU()
)
)
)
(joint): LinearJoint()
(encoder): LinearExponentialEncoder(
(layers): Sequential(
(0): Linear(in_features=105, out_features=80, bias=True)
(1): BatchNorm1d(80, eps=1e-05, momentum=0.1, affine=True, track_running_stats=True)
(2): ReLU()
)
)
)
- No more contents. I'm lazy. I'll add more later.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file fish_nnpipeline-0.0.2.tar.gz.
File metadata
- Download URL: fish_nnpipeline-0.0.2.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7db7dc06dd4d657aa0bb51cc4f90e23447bad2603cdc6bd75cb364037efe6d5a
|
|
| MD5 |
9619dbe74a6956ade6b54da1cb76f2ad
|
|
| BLAKE2b-256 |
c7c52125d19f26ce4db7584d22a7a7be1541e0e253910d19bf93ce98aec4c5cf
|
File details
Details for the file fish_nnpipeline-0.0.2-py3-none-any.whl.
File metadata
- Download URL: fish_nnpipeline-0.0.2-py3-none-any.whl
- Upload date:
- Size: 11.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.12.8
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
fc9328279e63d278f1a5640f9636d787d3e6a5688447cd3738d10c93236826bc
|
|
| MD5 |
b3ea14d89220fbceb22b173baddd3273
|
|
| BLAKE2b-256 |
e64568c4b6dab19d50325961dc8f184a2fd6ce46a5d4ec669a29641a5ff64487
|