Skip to content

PyTorch の 自動微分アルゴリズムの再現実装

Notifications You must be signed in to change notification settings

yuji96/reinventing-torchgrad

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Reinventing-TorchGrad

PyTorch の 自動微分アルゴリズムの再現実装

graph LR
    -a --> _3(("exp")) --> v1["exp(-a)"]

           v4["1"] --> _4(("+"))
    v1["exp(-a)"] --> _4(("+"))  --> v3["1+exp(-a)"]

             v5["1"] --> _5(("/"))
    v3["1+exp(-a)"] --> _5(("/")) --> v6["1 / {1+exp(-a)}"]
Loading
import math
from autograd import Tensor, exp

a = Tensor(3)
s = 1 / (1 + exp(-a))
s.backward()

assert math.isclose(s.value, 1 / (1 + math.exp(-3)))  # OK
assert math.isclose(a.grad, s.value * (1 - s.value))  # OK

環境構築

MacOS, Linux

python -m venv venv
source venv/bin/activate
pip install -e .

Windows

python -m venv venv
venv\Scripts\activate
pip install -e .

About

PyTorch の 自動微分アルゴリズムの再現実装

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages