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.1.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.1-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.1.tar.gz.

File metadata

  • Download URL: autoneuronet-0.1.1.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.1.tar.gz
Algorithm Hash digest
SHA256 a9a6f1725e58cf64562c2cee01692c4283ae64768ff893f089922a904256a6c5
MD5 57ac9a2ad36febd97584effd286f00ed
BLAKE2b-256 054b0b93cc3b940953d1a172307e8f3962530d59113f541cf6a788271b1a5835

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for autoneuronet-0.1.1-cp313-cp313-macosx_26_0_arm64.whl
Algorithm Hash digest
SHA256 a51e6745701da84baedd9bba5eb2461798588c621ed32271508727877b75c9f4
MD5 16630505c6c0148ac186cdbe101c91fb
BLAKE2b-256 fdcc147ddab7f38b0903a435e4efdd41339e27e09f963b2a0ea98163902f4eed

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