Skip to main content

Simple gradient computation library in Python

Project description

NumGrad

Simple gradient computation library for Python.

Getting Started

pip install numgrad

Inspired by tensorflow, numgrad supports automatic differentiation in tensorflow v2 style using original numpy and scipy functions.

>>> import numgrad as ng
>>> import numpy as np  # Original numpy
>>>
>>> # Pure numpy function
>>> def tanh(x):
...     y = np.exp(-2 * x)
...     return (1 - y) / (1 + y)
...
>>> x = ng.Variable(1)
>>> with ng.Graph() as g:
...     # numgrad patches numpy functions automatically here
...     y = tanh(x)
...
>>> g.gradient(y, [x])
(0.419974341614026,)
>>> (tanh(1.0001) - tanh(0.9999)) / 0.0002
0.41997434264973155

Build and Test

Contribute

Be sure to run the following command before developing

$ git clone https://github.com/ctgk/numgrad.git
$ cd numgrad
$ pre-commit install

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

numgrad-0.1.3.tar.gz (14.1 kB view details)

Uploaded Source

File details

Details for the file numgrad-0.1.3.tar.gz.

File metadata

  • Download URL: numgrad-0.1.3.tar.gz
  • Upload date:
  • Size: 14.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.0 CPython/3.9.10

File hashes

Hashes for numgrad-0.1.3.tar.gz
Algorithm Hash digest
SHA256 daa6b67f45b03f274dedf07375521b8b7314ec0ac2648d3d2e81f6d3ece8090b
MD5 85776af1758d574b545625d01d1570db
BLAKE2b-256 eecf4b87b14cf82cf85b340bccaf997b8671a66b0e43fcb34d9e8f01094ff3f8

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