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:

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):
        
        x = self.layer1(x)
        
        x = self.relu(x)
        
        x = self.sell(x)
        
        x = self.relu(x)
        
        x = self.layer3(x)
        
        return x
    
model = MyModule()

senn = ExpModule(in_features=5, out_features=10)

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!

![TIP] Run in your terminal:

pysenn

to see a little demonstration in action!

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.

6. 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.0

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.0
File Size Uploaded Provenance Actions
pysenn-0.3.0.tar.gz 9.1 kB Without provenance Details for pysenn-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 19.0 kB

Release files / pysenn-0.3.0.tar.gz

Download URL pysenn-0.3.0.tar.gz
Size 9.1 kB
Tags Source
SHA-256 checksum
How to use checksums
cbbee67a4cce5d4db167e79ea1894b252e36dfce7a14ea606ce4191850cd4bf1
BLAKE2b-256 checksum
How to use checksums
6d4058e9540238996ddc3942e60383e2448cd97f91c09cf3aa6c9cf4e979ab24
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.0-py3-none-any.whl

Download URL pysenn-0.3.0-py3-none-any.whl
Size 9.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5ae06a0713fe3d93e591ecba515fa189cf6f17b1f69fb90a09f8463f084e9bb3
BLAKE2b-256 checksum
How to use checksums
b3cf28620625bfa81fa12658aa4a2cf292aa7b3a1d505570ad40cfd447584920
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.0

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