16
GitHub - kaszperro/deepy
source link: https://github.com/kaszperro/deepy
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
README.md
deepy
Deep learning library written in python just for fun.
It uses numpy for computations. API is similar to PyTorch's one.
Examples:
-
In examples directory there is a MNIST linear classifier, which scores over 96% accuracy.
-
Sequential model creation:
from deepy.module import Linear, Sequential from deepy.autograd.activations import Softmax, ReLU my_model = Sequential( Linear(28 * 28, 300), ReLU(), Linear(300, 300), ReLU(), Linear(300, 10), Softmax() )
- Losses:
from deepy.module import Linear from deepy.autograd.losses import CrossEntropyLoss, MSELoss from deepy.variable import Variable import numpy as np my_model = Linear(10, 10) loss1 = CrossEntropyLoss() loss2 = MSELoss() good_output = Variable(np.zeros((10,10))) model_input = Variable(np.ones((10,10))) model_output = my_model(model_input) error = loss1(good_output, model_output) # now you can propagate error backwards: error.backward()
- Optimizers:
from deepy.module import Linear from deepy.autograd.losses import CrossEntropyLoss, MSELoss from deepy.variable import Variable from deepy.autograd.optimizers import SGD import numpy as np my_model = Linear(10, 10) loss1 = CrossEntropyLoss() loss2 = MSELoss() optimizer1 = SGD(my_model.get_variables_list()) good_output = Variable(np.zeros((10,10))) model_input = Variable(np.ones((10,10))) model_output = my_model(model_input) error = loss1(good_output, model_output) # now you can propagate error backwards: error.backward() # and then optimizer can update variables: optimizer1.zero_grad() optimizer1.step()
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK