Neural Network With Numpy
Neural Network With Numpy
MIT License
1 star 0 forks
Star Notifications
main Go to file
Javicadserres … on 9 Jul
View code
README.md
DNet
Neural Network framework implementation with numpy.
Installation
Normal user:
alternatively:
Developer:
https://github.com/Javicadserres/DNet 1/5
17/9/21 1:59 GitHub - Javicadserres/DNet: Deep Neural Network framework implementation with numpy.
Tests
To run tests you must install the library as a developer .
cd DNet/
pytest -v tests/
Usage
Import libraries
import numpy as np
import pandas as pd
import matplotlib.pyplot as plt
digits = load_digits()
https://github.com/Javicadserres/DNet 2/5
17/9/21 1:59 GitHub - Javicadserres/DNet: Deep Neural Network framework implementation with numpy.
images = digits.images
m, h, w = images.shape
images = images.reshape(m, 1, h, w)
target = digits.target
def one_hot_encoding(Y):
"""
One hot enconding method.
"""
one_hot = np.zeros((Y.size, Y.max() + 1))
one_hot[np.arange(Y.size), Y] = 1
return one_hot
model.add(Flatten())
model.add(LinearLayer(16, 10))
if epoch % 500 == 0:
print ("Cost after iteration %epoch: %f" %(epoch, cost))
costs.append(cost)
plt.figure(figsize=(7, 3))
plt.plot(costs_ss)
plt.ylabel('cost')
plt.xlabel('iterations (per hundreds)')
plt.title('Loss per epoch')
plt.show()
Check test.
predictions = model.forward(x_test.T)
predictions = predictions.argmax(axis=0)
for ax, image, label, pred in zip(axes, x_test.reshape((719, 8, 8)), y_test, predicti
ax.set_axis_off()
ax.imshow(image, cmap=plt.cm.gray_r, interpolation='nearest')
ax.set_title('Test: ' +str(label) + ' predicted: ' + str(pred))
https://github.com/Javicadserres/DNet 4/5
17/9/21 1:59 GitHub - Javicadserres/DNet: Deep Neural Network framework implementation with numpy.
Releases 2
v1.1 Latest
on 9 Jul
+ 1 release
Packages
No packages published
Languages
Python 100.0%
https://github.com/Javicadserres/DNet 5/5