Skip to main content

🧠 Neutro: The "Old School" Deep Learning Playground

codecov License: MIT

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.

🔄 Autograd — From Scratch, In NumPy

Unlike TensorFlow or JAX, neutro doesn't import a third-party autograd engine — it is its own autograd engine.

We built neutro.autograd from scratch in pure NumPy: a Tensor wrapper with a GradientTape that records every operation and computes gradients via reverse-mode AD. Ops like softmax, matmul, and relu all register backward closures on the tape.

Two ways to learn backprop:

  1. The Tape (default): Most layers use base.Layer.backward() which re-runs the forward pass inside a GradientTape and lets the tape compute all gradients automatically. This is clean, composable, and easy to maintain.

  2. The Manual Way: Any layer can override backward(grad_output) and compute gradients with explicit chain rule math. This is still supported and used by a few layers where the educational value of hand-writing the gradient is highest.

Both paths teach you something. The tape shows you how autograd engines work internally (docs/autograd/). The manual path shows you the actual chain rule math for each layer.


🚀 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 im2col for 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 numpy and scipy. 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)

📚 Documentation

Every component is documented with line-by-line walkthroughs, math, and references to the original research papers.

👉 Browse the full documentation →


🧠 Deep Dives & Nerdy Stuff

We documented everything because we know you like to check the math:


🧪 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.

Metadata

Release files for neutro 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 neutro 0.3.0
File Size Uploaded Provenance Actions
neutro-0.3.0.tar.gz 64.3 kB With provenance Details for neutro-0.3.0.tar.gz

Built distribution (wheel)

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

Total release size: 155.2 kB

Release files / neutro-0.3.0.tar.gz

Download URL neutro-0.3.0.tar.gz
Size 64.3 kB
Tags Source
SHA-256 checksum
How to use checksums
41da3ed47bdecb1f5b2f2a9ec12c623f7e1d2fe1417154ad66b2774c65afc574
BLAKE2b-256 checksum
How to use checksums
65a0144896b2b63ffdbf397eb9b04bccec20879377897777fd31aee059067e24
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 4, 2026.

Transparency log

Release files / neutro-0.3.0-py3-none-any.whl

Download URL neutro-0.3.0-py3-none-any.whl
Size 90.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
8a964ebd6f2e8451db8569fe2d2ee4a0d0923b1fdc4ad2157715b77b0cfedfc6
BLAKE2b-256 checksum
How to use checksums
bc85899f5db671ef0fff9fcb51aa8a4dd571467c49a72d1d642ade4d7aaa9838
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.13.12

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 4, 2026.

Transparency log

Security for neutro 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.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for neutro-0.3.0.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Jul 4, 2026.

Transparency log

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