Skip to main content

[!WARNING] This repo is outdated: development moved to:
https://pypi.org/project/pyyeast/ (PyPI package)
https://github.com/alessioparolini2011/PyYeast (GitHub repo)

autoNN logo

Python PyTorch

A Python package, based on PyTorch, to build self-expanding Neural Networks and train them with an optimized process.

I'm building it because I want to make SENN easier to create and manage. I'm starting from scratches, for create a really efficient and optimized structure.

File Structure

PySENN/
├── src/
│   └── pysenn/
│       ├── __init__.py
│       ├── __main__.py
│       ├── playground/      # this directory has no __init__.py because hasn't got resources to use, only my practice with PyTorch essentials
│       │   ├── _01_tensors.py
│       │   └── _02_operations.py
│       ├── sell/
│       │   ├── __init__.py
│       │   ├── linear.py       # ExpLayer (SELL)
│       │   ├── filter.py       # FilterLayer
│       │   └── module.py       # ExpModule
│       └── utils/
│           ├── __init__.py
│           └── randomdata.py
├── assets/
├── dist/
├── pyproject.toml
├── uv.lock
└── README.md

ExpLayer (SELL):

The core layer
It is the core of the package: is built starting from a nn.Module (avoiding the nn.Linear limits) to have a full-customizable structure. So I've built a linear layer that can expand his structure, adding new neurons and improving automatically the neural network power.

FilterLayer:

The bridge
A static layer would break if the previous layer grows from 8 to 12 neurons. So I've built FilterLayer, a layer that takes the variable output of a SELL and return always the same sizes Tensor, keeping the flow stable.

ExpModule:

The container
Groups one ExpLayer + one FilterLayer (putting a ReLU between them) inside a nn.ModuleList. So you can implement SELL in your nn much easier, because you can use it like a normal layer, it handles everything automatically for you

Quickstart

You need Python 3.12 on your machine

To install the package, run:

pip install pysenn

As I showed before, you can use a ExpModule to implement a SELL in your nn:

import torch
from pysenn.sell import ExpModule

x = torch.randn(8, 10)

module = ExpModule(in_features=10,
                   out_features=22)  # use it like a normal layer, the features inside manage everything for you

x = module(x) # use it like a normal module

print(x.size()) # out: 8, 22

module.expand(4) # add 4 neurons

x = module(x)  

print(x.size()) # out: 8, 26

[!WARNING] Because of the self-expanding structure, for now the package doesn't work with optimizers (optimizers like ADAM have a gradients memory that crashes if you add new). The only way is using SGD optimizer and recreating it every time you expand the neural network. See below.

Here's how you should do to use an SGD optimizer:

[!TIP] Run in your terminal:

pysenn

to see the demonstration (click here for the full file)! You can also see a little preview of the demonstration file here:

from torch import nn

from torch import optim

from pysenn.sell import ExpModule


class MyModule(nn.Module):
    
    def __init__(self):
        
        super().__init__()
        
        self.relu = nn.ReLU()
        
        self.layer1 = nn.Linear(in_features=1, out_features=5)
        
        self.sell = ExpModule(in_features=5, out_features=10)
        
        self.layer3 = nn.Linear(in_features=10, out_features=1)
        
    def forward(self, x):
        
        # the model passes the input tensor in all the layers + relu
        
        return x
    
model = MyModule()

optimizer = optim.SGD(model.parameters(), lr=0.01)  # model is a fake nn.Module with static and self-expanding layers

... # training process

senn.expand(4)  # expand

optimizer = optim.SGD(model.parameters(), lr=0.01)  # CREATE A NEW OPTIMIZER!

Credits

Built with:

  • PyTorch - for all tensor operations, autograd and nn.Module base
  • Hack Club - for the Terra program, feedback and the Week 1 ship motivation

Without PyTorch this project would not be possible. Thanks to Hack Club for supporting student-built open source.

Author

Alessio Parolini

Student Developer, Italy

Project: PySENN (formerly autoNN) - Self Expanding Neural Networks

Focus: PyTorch, dynamic architectures, efficient training

GitHub: Alessio Parolini

PyPI: pysenn

Metadata

Release files for pysenn 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for pysenn 0.3.2
File Size Uploaded Provenance Actions
pysenn-0.3.2.tar.gz 9.2 kB Without provenance Details for pysenn-0.3.2.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for pysenn 0.3.2
File Interpreter ABI Platform Actions
pysenn-0.3.2-py3-none-any.whl Python 3 none any Details for pysenn-0.3.2-py3-none-any.whl

Total release size: 19.2 kB

Release files / pysenn-0.3.2.tar.gz

Download URL pysenn-0.3.2.tar.gz
Size 9.2 kB
Tags Source
SHA-256 checksum
How to use checksums
15a346cef7d9d85a2445eb843b7176bf61df8222615033c7acfe40f499e4f79c
BLAKE2b-256 checksum
How to use checksums
26b08cd12b2cacbfc7ae35c8c4c2cff6be8671084403f6a8779397c34ca01bdf
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Release files / pysenn-0.3.2-py3-none-any.whl

Download URL pysenn-0.3.2-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8cfaef9261b1ef38d6bcc5efd8cb149db33fec146daa8b8451d190f725523668
BLAKE2b-256 checksum
How to use checksums
858c12bc8ee9ed779d62c6f109f9105224669f282ad36249b471fe4cb814e3ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.0

Security for pysenn 0.3.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page