Skip to main content

A modular Deep Learning framework built from scratch using NumPy

Project description

npmlp-core: Modular Deep Learning Framework from Scratch

A lightweight, modular deep learning library built entirely in NumPy. This project implements the core components of modern neural networks, including backpropagation, vectorized optimization, and advanced regularization techniques, without the use of high-level frameworks like PyTorch or TensorFlow.

Installation

pip install npmlp-core

Quick Start

import numpy as np
from mytorch.models import MLP1
from mytorch.optim import SGD
from mytorch.nn import CrossEntropyLoss

# Create a model (input: 784, output: 10 classes)
model = MLP1(784, 10)

# Set up optimizer and loss
optimizer = SGD(model.parameters(), lr=0.01, momentum=0.9)
criterion = CrossEntropyLoss()

# Training step
x = np.random.randn(32, 784)  # batch of 32
y = np.random.randint(0, 10, 32)  # labels

# Forward pass
output = model.forward(x)
loss = criterion.forward(output, y)

# Backward pass
grad = criterion.backward()
model.backward(grad)

# Update weights
optimizer.step()
optimizer.zero_grad()

Key Features

  • Core Layers: Fully functional Linear layers with comprehensive backpropagation.
  • Advanced Activations: Implementation of ReLU, Sigmoid, Tanh, and modern industry-standard functions like GELU (Gaussian Error Linear Units) and Swish.
  • Regularization: Vectorized BatchNorm1d with training/inference mode logic and running statistics.
  • Optimizers: Stochastic Gradient Descent (SGD) with configurable Momentum.
  • Loss Functions: MSELoss and CrossEntropyLoss with numerically stable Softmax integration.
  • Architectures: Pre-configured Multi-Layer Perceptron (MLP) models ranging from shallow (MLP0) to deep (MLP4) configurations.

Technical Highlights

1. Vectorized Backpropagation

Every layer in this library implements its own forward and backward pass. The gradients are calculated using vectorized matrix calculus, ensuring high performance on the CPU.

2. Numerical Stability

The Softmax and CrossEntropy implementations include numerical stability techniques (such as the max-subtraction method) to prevent floating-point overflow during exponentiation.

3. Training vs. Inference Mode

The BatchNorm1d layer manages global running means and variances using exponential moving averages (momentum), ensuring the models perform accurately during evaluation on single samples.

Project Structure

mlp-core/
├── src/
│   └── mytorch/
│       ├── nn/         # Layers (Linear, BatchNorm) and Activations
│       ├── optim/      # SGD with Momentum
│       ├── models/     # MLP Architectures
│       └── loss.py     # MSE and Cross-Entropy
├── requirements.txt    # Minimal dependencies (NumPy, SciPy)
└── README.md

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 Distributions

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

npmlp_core-1.0.0-cp312-cp312-win_amd64.whl (166.3 kB view details)

Uploaded CPython 3.12Windows x86-64

npmlp_core-1.0.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.2 MB view details)

Uploaded CPython 3.12manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

npmlp_core-1.0.0-cp312-cp312-macosx_11_0_arm64.whl (179.1 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

npmlp_core-1.0.0-cp312-cp312-macosx_10_13_x86_64.whl (180.1 kB view details)

Uploaded CPython 3.12macOS 10.13+ x86-64

npmlp_core-1.0.0-cp311-cp311-win_amd64.whl (167.7 kB view details)

Uploaded CPython 3.11Windows x86-64

npmlp_core-1.0.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (1.0 MB view details)

Uploaded CPython 3.11manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

npmlp_core-1.0.0-cp311-cp311-macosx_11_0_arm64.whl (177.7 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

npmlp_core-1.0.0-cp311-cp311-macosx_10_9_x86_64.whl (178.8 kB view details)

Uploaded CPython 3.11macOS 10.9+ x86-64

npmlp_core-1.0.0-cp310-cp310-win_amd64.whl (167.8 kB view details)

Uploaded CPython 3.10Windows x86-64

npmlp_core-1.0.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (998.0 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

npmlp_core-1.0.0-cp310-cp310-macosx_11_0_arm64.whl (179.0 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

npmlp_core-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl (180.6 kB view details)

Uploaded CPython 3.10macOS 10.9+ x86-64

npmlp_core-1.0.0-cp39-cp39-win_amd64.whl (168.4 kB view details)

Uploaded CPython 3.9Windows x86-64

npmlp_core-1.0.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl (990.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.17+ x86-64manylinux: glibc 2.5+ x86-64

npmlp_core-1.0.0-cp39-cp39-macosx_11_0_arm64.whl (179.8 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

npmlp_core-1.0.0-cp39-cp39-macosx_10_9_x86_64.whl (181.4 kB view details)

Uploaded CPython 3.9macOS 10.9+ x86-64

File details

Details for the file npmlp_core-1.0.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: npmlp_core-1.0.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 166.3 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for npmlp_core-1.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 c885a68aaed6cd11c2acd47930e06667178cf9181df310d9d52426234411ecc3
MD5 5f9be342ccf05a58067e2ca2d3851e45
BLAKE2b-256 cbde79e2b58a3bf64702596d61dbbb14535da7cb241d1c00230fd75ba68193e4

See more details on using hashes here.

Provenance

The following attestation bundles were made for npmlp_core-1.0.0-cp312-cp312-win_amd64.whl:

Publisher: build-wheels.yml on kkipngenokoech/mlp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file npmlp_core-1.0.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for npmlp_core-1.0.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 f8437cbdeff2c7f54fca58dcd73faa0a37ea1ab9dc686c0fe625674e46105f24
MD5 c55f60dd0f00cc609117974bd722e6ba
BLAKE2b-256 396830747f6d4e1304a84b8a2ad65be522f31e89adb6a8dddf9c564b44e9f2d8

See more details on using hashes here.

Provenance

The following attestation bundles were made for npmlp_core-1.0.0-cp312-cp312-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build-wheels.yml on kkipngenokoech/mlp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file npmlp_core-1.0.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for npmlp_core-1.0.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 1df8be3beadccd7c008ddaaaa79a2b0dc3463afa45c21eb2408356ed5734f48c
MD5 40a8b5b80b828a67e93276ed9b90658e
BLAKE2b-256 a444ca188174a795162022c9079e1473cf2b5be5bc39aa4e56638170fa7d93e2

See more details on using hashes here.

Provenance

The following attestation bundles were made for npmlp_core-1.0.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: build-wheels.yml on kkipngenokoech/mlp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file npmlp_core-1.0.0-cp312-cp312-macosx_10_13_x86_64.whl.

File metadata

File hashes

Hashes for npmlp_core-1.0.0-cp312-cp312-macosx_10_13_x86_64.whl
Algorithm Hash digest
SHA256 250c9b6a1747a0e6d8ed42209e3ceb6549e58e30b7e9bdc6df3ad9b8ac8e350f
MD5 50f802cdfae252e611eaba63a1671ea4
BLAKE2b-256 40fc9d1bb6ddbad2d5d43dee027b42b9b421469cc0ea1821d21b0fe9fcfcfa18

See more details on using hashes here.

Provenance

The following attestation bundles were made for npmlp_core-1.0.0-cp312-cp312-macosx_10_13_x86_64.whl:

Publisher: build-wheels.yml on kkipngenokoech/mlp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file npmlp_core-1.0.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: npmlp_core-1.0.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 167.7 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for npmlp_core-1.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 2bd8417b504a68b4929313d90f2b3f3b4b19b9d6052fd517b27eecf032b179c9
MD5 649f5fc9b4de9a00f9c8f3d0e0683cfb
BLAKE2b-256 845585d177a4c990c085d4928af21752572152326fb52b4b15cc50edb828e3d5

See more details on using hashes here.

Provenance

The following attestation bundles were made for npmlp_core-1.0.0-cp311-cp311-win_amd64.whl:

Publisher: build-wheels.yml on kkipngenokoech/mlp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file npmlp_core-1.0.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for npmlp_core-1.0.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 28e9dd55055c2a614f2728510e15abe4bb9a82e10efd37f1131d43941209590c
MD5 1cdc8d6e77724431406908f2b34d7449
BLAKE2b-256 d056f947bb161c9f24aad34b39cb2f56c786f99377d6f6ede8fc772ec99ac6ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for npmlp_core-1.0.0-cp311-cp311-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build-wheels.yml on kkipngenokoech/mlp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file npmlp_core-1.0.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for npmlp_core-1.0.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 bfd061c2443048658ce836679601ab2b9abbc0c563c9026b75258cd2b6e7841e
MD5 555e01c7341c7ee87c63b948b49ffda7
BLAKE2b-256 622d6b251f70810a16b11cd3cec18ad63ec15cdc97fcae43b668050b56d17848

See more details on using hashes here.

Provenance

The following attestation bundles were made for npmlp_core-1.0.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: build-wheels.yml on kkipngenokoech/mlp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file npmlp_core-1.0.0-cp311-cp311-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for npmlp_core-1.0.0-cp311-cp311-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 35fc2d8918eb2787da2ada7bf249a80cf701bfdd7577cf26151391ad6d9f5cb9
MD5 d1bfe9971ff7228d0c3247cf4a2f80cf
BLAKE2b-256 180b94302a18c4216cd969e0b528ea93a3c9ce5df69129de612c68a478898692

See more details on using hashes here.

Provenance

The following attestation bundles were made for npmlp_core-1.0.0-cp311-cp311-macosx_10_9_x86_64.whl:

Publisher: build-wheels.yml on kkipngenokoech/mlp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file npmlp_core-1.0.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: npmlp_core-1.0.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 167.8 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for npmlp_core-1.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 79a646c6d0e7e70543f911d2beaec06059864c525febe69d2023a055c57d34a9
MD5 748c3cec80cb270079f8a6c7c9c370c0
BLAKE2b-256 ab84e03dd87ad47e7f0f480b1e97aac5a9004f6b9f864ac9867630f4639e36f6

See more details on using hashes here.

Provenance

The following attestation bundles were made for npmlp_core-1.0.0-cp310-cp310-win_amd64.whl:

Publisher: build-wheels.yml on kkipngenokoech/mlp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file npmlp_core-1.0.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for npmlp_core-1.0.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 450673a2e597e1f47f0195e7dd57019e235faf235494d20fa2d63afc140dc0b6
MD5 3819aa2772238414c40f62731a627203
BLAKE2b-256 1f5beb752dffa48e26e8e7953ef382ac5100f495a70e6802a774a80486fa4eb3

See more details on using hashes here.

Provenance

The following attestation bundles were made for npmlp_core-1.0.0-cp310-cp310-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build-wheels.yml on kkipngenokoech/mlp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file npmlp_core-1.0.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for npmlp_core-1.0.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 245ed89fb5135d78369d4631c0af3c13ba089c59dbb02504efde9e28b125550c
MD5 79bc3205b11395d585b22f30c36458d2
BLAKE2b-256 fec69e66c2c06346599f25b7b126d1b9dbdbc0a0b41729d3fcc1fba38c1e772e

See more details on using hashes here.

Provenance

The following attestation bundles were made for npmlp_core-1.0.0-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: build-wheels.yml on kkipngenokoech/mlp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file npmlp_core-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for npmlp_core-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 e6bcd841ccddae47e076bb30b74ea0996a469a194a1a0871b58255a79857889d
MD5 eb6dc1db0284bdf8574eb9165090fe92
BLAKE2b-256 c30d99014842db4c139eca7f4c46ef5e816665e2bd2989ffa0c87d070fb0c4ab

See more details on using hashes here.

Provenance

The following attestation bundles were made for npmlp_core-1.0.0-cp310-cp310-macosx_10_9_x86_64.whl:

Publisher: build-wheels.yml on kkipngenokoech/mlp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file npmlp_core-1.0.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: npmlp_core-1.0.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 168.4 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for npmlp_core-1.0.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 7a0285a86f688cd9c7fc1d303b3b8546d79f20ad0b413f2aa70ea330f3e3413e
MD5 0a51d1a350017c93f309cbac057416d5
BLAKE2b-256 8948e6962e2a415aa123d5176075d2cb0333dbbd55c91d82ed809ec1496818f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for npmlp_core-1.0.0-cp39-cp39-win_amd64.whl:

Publisher: build-wheels.yml on kkipngenokoech/mlp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file npmlp_core-1.0.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for npmlp_core-1.0.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 9acc0e44c0b0470f2b4c0aabe748237eabb09e766ad7582ebcc945b31dba782f
MD5 ea1251e1b8e1afce8193f9631de1270c
BLAKE2b-256 9c034d4b9ce95ff9a698e48ea4a9e356adc9c666caeeec7ea0ce032bf31b5fc5

See more details on using hashes here.

Provenance

The following attestation bundles were made for npmlp_core-1.0.0-cp39-cp39-manylinux_2_5_x86_64.manylinux1_x86_64.manylinux_2_17_x86_64.manylinux2014_x86_64.whl:

Publisher: build-wheels.yml on kkipngenokoech/mlp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file npmlp_core-1.0.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for npmlp_core-1.0.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 30d4c1fa7c2d811928532bb057f8f033e89453249035a81b954cdbcaa10d42ea
MD5 8828817277cf76a46ebefc93127cc9e1
BLAKE2b-256 d3107e424cd36100808af9edca0f83b1e4d0f838342c69da7f0f72e9d3287289

See more details on using hashes here.

Provenance

The following attestation bundles were made for npmlp_core-1.0.0-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: build-wheels.yml on kkipngenokoech/mlp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file npmlp_core-1.0.0-cp39-cp39-macosx_10_9_x86_64.whl.

File metadata

File hashes

Hashes for npmlp_core-1.0.0-cp39-cp39-macosx_10_9_x86_64.whl
Algorithm Hash digest
SHA256 1581be1fd408b5b81c6a2ce304334e2a6ef0334d21882c221f56dbdfe7f855aa
MD5 28dc8291be2d0801a6fa42da1bf1c357
BLAKE2b-256 dd9763112eb53370639832e7e1584277a303b1184233c539c9bbc76771bf408e

See more details on using hashes here.

Provenance

The following attestation bundles were made for npmlp_core-1.0.0-cp39-cp39-macosx_10_9_x86_64.whl:

Publisher: build-wheels.yml on kkipngenokoech/mlp

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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