Skip to 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.

License

Notifications You must be signed in to change notification settings

Sai-Suraj-27/QuarkNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

🚀 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.],
    ]
)

About

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.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 2

  •  
  •  

Languages