Skip to main content

A neural network framework built completely from scratch using NumPy

Project description

NeuralNetworkFromScratch

A lightweight Python library implementing a fully functional neural network from scratch using NumPy, without relying on machine learning frameworks such as TensorFlow or PyTorch.

The goal of this project is to provide a clear and educational implementation of neural networks, including forward propagation, backpropagation, normalization, and regularization techniques.


Features

  • Fully connected neural network implementation
  • Modular layer system
  • Forward and backward propagation
  • Batch normalization
  • Dropout regularization
  • ReLU and Softmax activation functions
  • Dataset scaling utilities
  • Train / validation split helpers

Installation

Install from PyPI:

pip install neuralnetwork-from-scratch

Or install from source:

git clone https://github.com/Sendy45/NeuralNetworkFromScratch.git
cd neuralnetworknumpy
pip install .

Example Usage

import numpy as np
from keras.datasets import mnist

from neuralnetworknumpy import (
    NeuralNetwork,
    Dense,
    ReLu,
    BatchNorm,
    Dropout,
    Softmax
)

# load dataset
(X_train, y_train), _ = mnist.load_data()

# flatten images
X_train = X_train.reshape(-1, 784) / 255.0

model = NeuralNetwork([
    Dense(64, inputs=784),
    ReLu(),
    BatchNorm(),
    Dropout(0.1),
    Dense(10),
    Softmax()
])

model.compile(
    optimizer="adam",
    loss="categorical_crossentropy"
)

model.fit(X_train, y_train, epochs=10, batch_size=32)

Project Structure

NeuralNetworkFromScratch
│
├── neuralnet
│   ├── __init__.py
│   ├── network.py
│   ├── layers.py
│   ├── activations.py
│   └── utils.py
│
├── tests
├── README.md
└── pyproject.toml

Goals of the Project

This project was designed to:

  • Demonstrate how neural networks work internally
  • Provide a clean NumPy-based implementation
  • Serve as an educational resource for learning deep learning fundamentals

Unlike production ML frameworks, this project prioritizes clarity and learning over performance.


Dependencies

  • numpy
  • tqdm

Optional dependencies used in examples:

  • matplotlib
  • keras (for datasets such as MNIST)

License

This project is licensed under the MIT License.


Author

Created by Itamar Senderovitz.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

neuralnetworknumpy-0.1.0-py3-none-any.whl (11.3 kB view details)

Uploaded Python 3

File details

Details for the file neuralnetworknumpy-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for neuralnetworknumpy-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1f107ea44d1724b3b196218e129fb56a03d75977b0d1acc642cf1be9d14e3286
MD5 3da73cda43b73e664c493f6069fabf7e
BLAKE2b-256 3b8047fdede3c5251f297e0f7c3ede6841ab6ad0344962946aab8668b78e7670

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page