atomgrad
1.0.0

AtomGrad는 신경망 API 라이브러리와 결합 된 벡터 값 및 스칼라 값 텐서 (AM)에서 자동 도피를 수행하는 마이크로 그라드와 작은 그레이드 사이에있는 간단한 오토 그라드 엔진입니다.
sum , exp , reshape , randint , uniform 등)를 지원합니다.relu , sigmoid , tanh 등과 같은 활성화 기능을 지원합니다.binary_cross_entropy & binary_accuracy 지원합니다.PIP를 사용하여 AtomGrad를 설치할 수 있습니다.
pip install atomgrad==0.3.0다음은 Atomgrad를 사용하여 기능의 기울기를 계산하는 간단한 예입니다.
from atomgrad . atom import Atom
from atomgrad . graph import draw_dot
# create two tensors with gradients enabled
x = Atom ( 2.0 , requires_grad = True )
y = Atom ( 3.0 , requires_grad = True )
# define a function
z = x * y + x ** 2
# compute the backward pass
z . backward ()
# print the gradients
print ( x . grad ) # 7.0
print ( y . grad ) # 2.0
draw_dot ( z )
다음은 이진 분류를 위해 Atomgrad를 사용하여 16 노드 숨겨진 계층 신경 네트워크를 훈련시키는 간단한 예입니다.
import numpy as np
from atomgrad . atom import Atom
from atomgrad . nn import AtomNet , Layer
from atomgrad . optim import SGD
from atomgrad . metrics import binary_cross_entropy , binary_accuracy
# create a model
model = AtomNet (
Layer ( 2 , 16 ),
Layer ( 16 , 16 ),
Layer ( 16 , 1 )
)
# create an optimizer
optim = SGD ( model . parameters (), lr = 0.01 )
# load some data
x = [[ 2.0 , 3.0 , - 1.0 ],
[ 3.0 , - 1.0 , 0.5 ],
[ 0.5 , 1.0 , 1.0 ],
[ 1.0 , 1.0 , - 1.0 ],
[ 0.0 , 4.0 , 0.5 ],
[ 3.0 , - 1.0 , 0.5 ]]
y = [ 1 , 1 , 0 , 1 , 0 , 1 ]
x = Atom ( x )
y = Atom ( y )
model . fit ( x , y , optim , binary_cross_entropy , binary_accuracy , epochs = 100 )
#output
'''
...
epoch: 30 | loss: 0.14601783454418182 | accuracy: 100.0%
epoch: 35 | loss: 0.11600304394960403 | accuracy: 100.0%
epoch: 40 | loss: 0.09604986757040024 | accuracy: 100.0%
epoch: 45 | loss: 0.0816292017698288 | accuracy: 100.0%
''' make_moons 데이터 세트 및 MNIST 숫자 데이터 세트를 포함한 간단한 자동 도구 및 4 개의 바이너리 분류기의 예는 examples/demos.ipynb 노트북에 있습니다.
참고 : atom.nn 에는 softmax 활성화 및 cat_cross_entropy 포함되어 있지만 모델 결과는 상당히 분리되어 일부 버그 때문일 수 있습니다 (PLZ LMK를 찾으면). 결과적으로 AtomNet 모델은 이진 분류 신경 순 작업에 가장 적합합니다.