Skip to content
/ NN Public

Implementing an Artificial Neural Network (ANN) from scratch using Python.

Notifications You must be signed in to change notification settings

fawern/NN

Repository files navigation

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.

About

Implementing an Artificial Neural Network (ANN) from scratch using Python.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages