Skip to content

Latest commit

 

History

History
46 lines (31 loc) · 944 Bytes

README.md

File metadata and controls

46 lines (31 loc) · 944 Bytes

Artificial Neural Network (ANN) from scrathc.

This is a simple implementation of a neural network from scratch using only numpy.

How to use it?

from Nn import Layers
from Nn import NInput
from Nn import NLayer

X = np.array([[0,0],[0,1],[1,0],[1,1]])
y = np.array([[0],[1],[1],[0]])

model = Layers()

model.add(NInput(2))
model.add(NLayer(4, activation='tanh'))
model.add(NLayer(4, activation='tanh'))
model.add(NLayer(1, activation='sigmoid'))

model.fit_model(X, y, epochs=10000, learning_rate=0.1)
print(model.evaluate_trained_model())

"""
Output:
(1.0, array([[8, 0],
             [0, 4]],dtype=int64))
"""
model.show_loss_graph()

loss_plot

Information about the classes

  • NInput: This is the input layer, it has no activation function and it's only used to define the input shape of the model.
  • NLayer: This is the Multi Layer Perceptron (MLP) layer.