kiwigrad
1.0.0

Apesar de não ter a capacidade de voar pelos céus como Pytorch e Tensorflow , o Kiwigrad ainda é um pássaro formidável que está repleto de potencial inexplorado esperando para ser descoberto.
Kiwigrad? Sim, é outra versão do MicroRrad que foi criada apenas para diversão e experimentação.
Para instalar a versão atual,
pip install kiwigrad==0.28 Kiwigrad é uma versão modificada dos pacotes MicroRrad e Minigrad com recursos adicionais. Os principais recursos adicionados a Kiwigrad são:
from kiwigrad import MLP , Layer
class PotNet ( MLP ):
def __init__ ( self ):
layers = [
Layer ( nin = 2 , nout = 16 , bias = True , activation = "relu" ),
Layer ( nin = 16 , nout = 16 , bias = True , activation = "relu" ),
Layer ( nin = 16 , nout = 1 , bias = True , activation = "linear" )
]
super (). __init__ ( layers = layers )
model = PotNet () from kiwigrad import Value , draw_dot
a = Value ( - 4.0 )
b = Value ( 2.0 )
c = a + b
d = a * b + b ** 3
c += c + Value ( 1. )
c += Value ( 1. ) + c + ( - a )
d += d * Value ( 2 ) + ( b + a ). relu ()
d += Value ( 3. ) * d + ( b - a ). relu ()
e = c - d
f = e ** 2
g = f / Value ( 2.0 )
g += Value ( 10.0 ) / f
print ( f' { g . data :.4f } ' ) # prints 24.7041, the outcome of this forward pass
g . backward ()
print ( f' { a . grad :.4f } ' ) # prints 138.8338, i.e. the numerical value of dg/da
print ( f' { b . grad :.4f } ' ) # prints 645.5773, i.e. the numerical value of dg/db
draw_dot ( g ) cd test
pytest .