Skip to main content

AutoNeuroNet is a fully implemented automatic differentiation engine with custom matrices and a full neural network architecture and training pipeline. It comes with Python bindings through PyBind11, allowing for quick and easy development of networks through Python, backed with C++ for enhanced speed and performance.

Project description

AutoNeuroNet logo

AutoNeuroNet is a fully implemented automatic differentiation engine with custom matrices and a full neural network architecture and training pipeline. It comes with Python bindings through PyBind11, allowing for quick and easy development of networks through Python, backed with C++ for enhanced speed and performance.

Install AutoNeuroNet with PIP:

pip install autoneuronet

See the full documentation at https://rishabsa.github.io/AutoNeuroNet/

Quickstart

To get started with AutoNeuroNet, import the package. AutoNeuroNet allows you to make automatically differentiable variables and matrices easily through the Var and Matrix classes, which store values and gradients as doubles.

Scalar Automatic Differentiation

import autoneuronet as ann

x = ann.Var(2.0)
y = x**2 + x * 3.0 + 1.0

# Set the final gradient to 1.0 and perform Backpropagation
y.setGrad(1.0)
y.backward()

print(f"y: {y.val}") # 11.0 = (2)^2 + 3x + 1
print(f"dy/dx: {x.grad}") # 7.0 = 2x + 3

Matrix Initialization

import autoneuronet as ann

X = ann.Matrix(10, 1)  # shape: (10, 1)
y = ann.Matrix(10, 1)  # shape: (10, 1)

for i in range(n_samples):
    X[i, 0] = ann.Var(i)
    y[i, 0] = 5.0 * i + 3.0 # y = 5x + 3

Matrix Math

import autoneuronet as ann

X = ann.Matrix(2, 2)
X[0] = [1.0, 2.0]
X[1] = [3.0, 4.0]

Y = ann.Matrix(2, 2)
Y[0] = [5.0, 6.0]
Y[1] = [7.0, 8.0]

# Z = ann.matmul(X, Y)
Z = X @ Y
print(Z)

# Output:
# Matrix(2 x 2) =
# 19.000000 22.000000
# 43.000000 50.000000

NumPy to Matrix

import autoneuronet as ann
import numpy as np

x = np.array([[1.0, 2.0], [3.0, 4.0]])
X = ann.numpy_to_matrix(x)
print(X)

# Output:
# Matrix(2 x 2) =
# 1.000000 2.000000
# 3.000000 4.000000

Neural Networks, Loss Functions, and Optimizers

AutoNeuroNet supports several types of layers, including Linear fully-connected layers and activations functions such as ReLU, Sigmoid, or Softmax.

import autoneuronet as ann
import numpy as np

model = ann.NeuralNetwork(
    [
        ann.Linear(784, 256, init="he"),
        ann.ReLU(),
        ann.Linear(256, 128, init="he"),
        ann.ReLU(),
        ann.Linear(128, 10, init="he"),
        ann.Softmax(),
    ]
)
optimizer = ann.SGDOptimizer(
    learning_rate=1e-2, model=model, momentum=0.9, weight_decay=1e-4
)

print(model)

AutoNeuroNet also supports several loss functions, such as the MSELoss, MAELoss, BCELoss, CrossEntropyLoss, and CrossEntropyLossWithLogits, and optimzers, such as GradientDescentOptimizer and SGDOptimizer.

loss = ann.MSELoss(labels, logits)
loss.setGrad(1.0)
loss.backward()

optimizer.optimize()
optimizer.resetGrad()

print(f"Loss: {loss.getVal()}")

Reference Resources used in the development of AutoNeuroNet:

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

autoneuronet-0.1.0.tar.gz (12.0 MB view details)

Uploaded Source

Built Distribution

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

autoneuronet-0.1.0-cp313-cp313-macosx_26_0_arm64.whl (173.1 kB view details)

Uploaded CPython 3.13macOS 26.0+ ARM64

File details

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

File metadata

  • Download URL: autoneuronet-0.1.0.tar.gz
  • Upload date:
  • Size: 12.0 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for autoneuronet-0.1.0.tar.gz
Algorithm Hash digest
SHA256 66f9860a41680385ed39afe1055e992625e741fd131ee09cff828563ad9c8e9e
MD5 316a6f9c5bf873d6a35ff9f330cbcbb6
BLAKE2b-256 a154a3995c4901167ad5d2a0644da36b9c3038d29486c9a15cd45c9b036c0cc4

See more details on using hashes here.

File details

Details for the file autoneuronet-0.1.0-cp313-cp313-macosx_26_0_arm64.whl.

File metadata

File hashes

Hashes for autoneuronet-0.1.0-cp313-cp313-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 dc82711b417cabefb1976ff9a46d45deba077633edde82242f45b46873979b16
MD5 e20ae476da1279e22bf061b0e949a61c
BLAKE2b-256 74211af937b8359c6f70741da3c58ff3b47317975bd48a2fd4abb73b4bf4c85b

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