A Keras-style deep learning library using NumPy and SciPy
Project description
🧠 Neutro: The "Old School" Deep Learning Playground
Neutro is a intentionally naive, NumPy-only implementation of modern deep learning architectures. It’s the Keras experience you love, powered by the NumPy you tolerate, built specifically for people who want to peek under the hood and actually understand how the gears turn.
👴 The Philosophy: Why Does This Exist?
Let's be honest: modern DL frameworks are black boxes. You pip install 4GB of binaries and suddenly you're "doing AI."
Neutro is for the curious, the learners, and the "old-school" folks like me who believe that if you can't build it in a matrix, you don't really know it.
- Learn, Don't just Run: Every line of code is designed to be readable. We don't hide behind C++ kernels or CUDA kernels. If you want to know how FlashAttention actually tiles memory, you can just read the Python file.
- A Toy, not a Tool: This isn't meant for production. It's a playground for learning advanced algorithms (MHA, GQA, FlashAttention, LSTM) in their purest form.
- For the Wisdom-Rich: If you remember when 64MB of RAM was a flex and "vectorization" meant loop unrolling, this is for you. It's a fun way to play with cutting-edge 2024 algorithms using 1990s-era clarity.
🚀 What's Inside?
- "I can't believe it's not Keras!": Your muscle memory is safe here.
.compile(),.fit(),.predict()—it’s all exactly where you left it. - Pure NumPy Math: We did the math so you don't have to. Every gradient, from Softmax to LSTM gates, is hand-derived and vectorized.
- Speed (for a CPU): We use
im2colfor convolutions and FlashAttention (yes, really) to keep your CPU fans humming in a way that sounds productive. - Zero Heavy Dependencies: Tired of downloading 4GB of CUDA binaries just to train on MNIST? We require exactly
numpyandscipy. That’s it.
🛠 Features That'll Make You Say "Wait, You Implemented That?"
| Category | The "Fancy" Stuff | Why You Should Care |
|---|---|---|
| Attention | FlashAttention, MQA, GQA, RoPE |
We have more attention variants than a distracted toddler. |
| Tokenization | BPETokenizer, RegexTokenizer |
Byte-level BPE with regex splitting, just like the big kids. |
| Vision | AlexNet, VGG16, VGG19, im2col |
Classical and modern vision architectures, vectorized. |
| LLMs | Llama, Qwen, DeepSeek (MoE) |
Yes, you can run a (very tiny) MoE model on your CPU. |
| Modern Ops | RMSNorm, SiLU, SwiGLU |
The secret sauce of modern LLMs, hand-implemented. |
| Optimizers | AdamW, Adam, SGD+Momentum |
Keep your weights from exploding like a bad science fair project. |
🏆 The Hall of Fame: Pre-built Architectures
Why build from scratch when we've already done the heavy lifting?
- The Visionaries:
AlexNet,VGG16,VGG19 - The Linguists:
GPT-2,LlamaTiny,QwenTiny,DeepSeekTiny(Mixture of Experts)
💻 Show Me The Code!
If you know Keras, you already know Neutro. It's that simple.
from neutro.models import Sequential
from neutro.layers import Conv2D, MaxPooling2D, Flatten, Dense, Dropout
# Build a CNN that actually fits in your head
model = Sequential([
Conv2D(32, kernel_size=3, activation='relu', input_shape=(28, 28, 1)),
MaxPooling2D(pool_size=2),
Flatten(),
Dense(128, activation='relu'),
Dropout(0.5),
Dense(10, activation='softmax')
])
# Compile it like it's 2015
model.compile(optimizer='adam', loss='categorical_crossentropy', metrics=['accuracy'])
# Fit it like a tailored suit
model.fit(train_flow, epochs=10)
📂 Deep Dives & Nerdy Stuff
We documented everything because we know you like to check the math:
- Attention Mechanisms - How we made FlashAttention work on a CPU.
- Convolutional Magic - The
im2coldeep dive. - Activations & Gradients - Proofs for the brave.
- Optimizers - Why AdamW is better than your ex.
🧪 Examples to Flex Your CPU
Check out the examples/ folder for end-to-end scripts:
mnist_cnn.py: Standard digit classification with real-time augmentation.wikitext_llm.py: A character-level Transformer that actually talks back.
🏗 Installation
git clone https://github.com/sourcepirate/neutro.git
cd neutro
pip install -e .
Disclaimer: This is a hobby project for learning and exploration. It is intentionally naive, likely inefficient compared to compiled kernels, and 100% focused on the joy of understanding advanced algorithms. If you're looking to change the world with AGI, go to PyTorch. If you're looking to understand why your Transformer works while drinking a nice cup of tea, you're in the right place.
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 neutro-0.1.0.tar.gz.
File metadata
- Download URL: neutro-0.1.0.tar.gz
- Upload date:
- Size: 51.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7a7339326df3143c8ed4bb8c01b9fc2e5691523f92cd8ea1d6e03cd6c1ea3c9
|
|
| MD5 |
fc100c39398639b645e707492ad98d89
|
|
| BLAKE2b-256 |
5edc8d9d1b0795a5a05a9f1e7fe44ab74e78e62373d9a7ef747dbb8208d9676d
|
Provenance
The following attestation bundles were made for neutro-0.1.0.tar.gz:
Publisher:
publish.yml on sourcepirate/neutro
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
neutro-0.1.0.tar.gz -
Subject digest:
d7a7339326df3143c8ed4bb8c01b9fc2e5691523f92cd8ea1d6e03cd6c1ea3c9 - Sigstore transparency entry: 1675291274
- Sigstore integration time:
-
Permalink:
sourcepirate/neutro@ea204109ad2f8f0ea477b9f9e0a4eb741cd1fe4b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sourcepirate
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ea204109ad2f8f0ea477b9f9e0a4eb741cd1fe4b -
Trigger Event:
workflow_dispatch
-
Statement type:
File details
Details for the file neutro-0.1.0-py3-none-any.whl.
File metadata
- Download URL: neutro-0.1.0-py3-none-any.whl
- Upload date:
- Size: 78.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
255548e42a1bfd9edcc94b6656d09f01a1b160f2162f0863efcb849b6fb2b1e9
|
|
| MD5 |
961e70a02b2d1dd234f461ed007bfc04
|
|
| BLAKE2b-256 |
1e881447e4ec69a0beddf1475eb742ba0ba474c7804d9d7b310a2c9b6ee92c31
|
Provenance
The following attestation bundles were made for neutro-0.1.0-py3-none-any.whl:
Publisher:
publish.yml on sourcepirate/neutro
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
neutro-0.1.0-py3-none-any.whl -
Subject digest:
255548e42a1bfd9edcc94b6656d09f01a1b160f2162f0863efcb849b6fb2b1e9 - Sigstore transparency entry: 1675291309
- Sigstore integration time:
-
Permalink:
sourcepirate/neutro@ea204109ad2f8f0ea477b9f9e0a4eb741cd1fe4b -
Branch / Tag:
refs/heads/main - Owner: https://github.com/sourcepirate
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@ea204109ad2f8f0ea477b9f9e0a4eb741cd1fe4b -
Trigger Event:
workflow_dispatch
-
Statement type: