Skip to main content

QuarkNet is a lightweight Deep learning library that's built entirely with NumPy and supports the essentials needed to train fully-connected feedforward neural networks.

Project description

QuarkNet

A minimal deep learning library built from scratch with just NumPy.

QuarkNet is a lightweight Deep learning library that's built entirely with NumPy and supports the essentials needed to train fully-connected feedforward neural networks.

Features

  • Fully Connected Linear Layers (Linear)
  • Activation Functions: Tanh, ReLU, Sigmoid
  • Loss Functions: Mean Squared Error (MSE)
  • Optimizer: Stochastic Gradient Descent (SGD)
  • Mini-batch Training with shuffling
  • Layer Stacking API for building networks
  • Prediction & Evaluation support
  • Pure NumPy Implementation — no external ML frameworks / Dependencies

Installation

Create a virtual environment using uv

uv venv .venv

Activate the virtual environment

source .venv/bin/activate

Install QuarkNet into your isolated .venv virtual environment

uv pip install quarknet

Alternatively, if you prefer traditional tools

python3 -m venv .venv      # Create a virtual environment
source .venv/bin/activate
pip install QuarkNet        # Standard pip install

Solving the XOR Problem with QuarkNet

The XOR (exclusive OR) problem is a classic example in neural networks because it is non-linear and cannot be solved by a single linear layer.

import numpy as np
from quarknet.nn import NeuralNet
from quarknet.layers import Linear
from quarknet.activations import Tanh
from quarknet.loss import MSE
from quarknet.optim import SGD

# XOR inputs
inputs = np.array([
    [0, 0],
    [0, 1],
    [1, 0],
    [1, 1]
])

# XOR outputs
targets = np.array([
    [0],
    [1], 
    [1],
    [0],
])

# Train the model
model.train(
    inputs=inputs,
    targets=targets,
    loss=MSE(),
    optimizer=SGD(),
    epochs=5000,
    batch_size=32,
    shuffle=True
)

# Make predictions
predictions = model.predict(inputs)
print("Predictions:\n", np.round(predictions))

Output

Predictions:
array(
    [
        [0.],
        [1.],
        [1.],
        [0.],
    ]
)

Project details


Download files

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

Source Distribution

quarknet-0.1.0.tar.gz (9.3 kB view details)

Uploaded Source

Built Distribution

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

quarknet-0.1.0-py3-none-any.whl (10.2 kB view details)

Uploaded Python 3

File details

Details for the file quarknet-0.1.0.tar.gz.

File metadata

  • Download URL: quarknet-0.1.0.tar.gz
  • Upload date:
  • Size: 9.3 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for quarknet-0.1.0.tar.gz
Algorithm Hash digest
SHA256 6229e077fb6af9530fe88179fc72e51efbfb38d103d6a7e202ecc86194cc3ddb
MD5 4ddf1abf2ad04ca91b3a1aee07c9ab47
BLAKE2b-256 d9745877dd91df4f0cf0c3aed7cfe5b656b705dbd1514ecd3f5e20370c1a2489

See more details on using hashes here.

File details

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

File metadata

  • Download URL: quarknet-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 10.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.3

File hashes

Hashes for quarknet-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 92cbe8aa792349185af589e035262a9484719c38420de32a07e71f4c00087117
MD5 a4bb6544863ab1e89b90076552702356
BLAKE2b-256 cee959c61029b91461f3b3fc1ba365981b8cf6034d44604785a0c77f209ea85a

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