Skip to main content

PyPI version info PyPI supported Python versions

Key Features

  • Forward and Backward pass on scalar values
  • Backpropagation with a computation graph
  • Activation Functions:
    • Sigmoid
    • ReLU
    • Softmax
  • Loss Criterion:
    • MSE
    • Cross Entropy

Installing

# using pip
pip install oxigrad

# using uv
uv add oxigrad

Note: Python 3.9 or higher is required

Quick Examples

Simple Neuron

from oxigrad import Value, Activation

x1 = Value(1.7, label="x1")
x2 = Value(-0.3, label="x2")

w1 = Value(-1.5, label="w1")
w2 = Value(0.1, label="w2")

b = Value(0.5, label="b")

# Set a label after an operation
x1w1 = (x1 * w1).set_label("x1w1")
x2w2 = x2 * w2

xwb = x1w1 + x2w2 + b

z = Activation.Sigmoid(xwb).set_label("z")

# Run backpropagation
z.backward()

print(z)    # Value(data=0.8889, grad=1.0000, label='z', operation='SIGMOID')
print(w1)   # Value(data=-1.5000, grad=0.1678, label='w1')
print(w2)   # Value(data=0.1000, grad=-0.0296, label='w2')
print(b)    # Value(data=0.5000, grad=0.0987, label='b')

Cross Entropy Loss

from oxigrad import Activation, Loss, Value

a = Value(1.63, label="logit_0")
b = Value(0.27, label="logit_1")

c = Value(1, label="target_0")
d = Value(0, label="target_1")

logits = [a, b]
targets = [c, d]

# Convert logits into probability scores (does not add to computation graph)
probability_scores = Activation.Softmax(logits)
print(probability_scores)       # [0.7957596977159083, 0.20424030228409182]
print(sum(probability_scores))  # 1.0

# Has build in softmax
loss = Loss.CrossEntropy(logits, targets).set_label("loss")
loss.backward()

print(loss) # Value(data=0.2285, grad=1.0000, label='loss', operation='CROSSENTROPY')
print(a)    # Value(data=1.6300, grad=-0.2042, label='logit_0')
print(b)    # Value(data=0.2700, grad=0.2042, label='logit_1')
print(c)    # Value(data=1.0000, grad=0.2285, label='target_0')
print(d)    # Value(data=0.0000, grad=1.5885, label='target_1')

Metadata

Release files for oxigrad 0.3.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for oxigrad 0.3.2
File Size Uploaded
oxigrad-0.3.2.tar.gz 16.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for oxigrad 0.3.2
File Interpreter ABI Platform
oxigrad-0.3.2-cp39-abi3-win_amd64.whl CPython 3.9 abi3 Windows x86-64 Details

Total release size: 180.3 kB

Release files / oxigrad-0.3.2.tar.gz

Download URL oxigrad-0.3.2.tar.gz
Size 16.5 kB
Tags Source
SHA-256 checksum
How to use checksums
2aa1b7b3607b9472b8464f9bcefb2876a4fa1893264db1480eb167bf8f8ec387
BLAKE2b-256 checksum
How to use checksums
3d037f9554241601d54d17f7bc78631b58633da1c68da6bdb1a8b429f5edfa44
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.9.0

Release files / oxigrad-0.3.2-cp39-abi3-win_amd64.whl

Download URL oxigrad-0.3.2-cp39-abi3-win_amd64.whl
Size 163.8 kB
Tags CPython 3.9 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
2a51697ee8614b28416a48eab2b0fc8f4ba8b59e932f0e954a6cd5ad2ebd65bf
BLAKE2b-256 checksum
How to use checksums
cf890b4670113780000755c6253ed9378c5060407014d1919686dc12bd6db18e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via maturin/1.9.0

Release history Release notifications | RSS feed

This release

0.3.2 This release

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page