Skip to main content

A simple neural network implementation.

Project description

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 fawern_nn.nn import Layers
from fawern_nn.nn import NInput
from fawern_nn.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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

fawern_nn-0.1.0.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

fawern_nn-0.1.0-py3-none-any.whl (6.2 kB view details)

Uploaded Python 3

File details

Details for the file fawern_nn-0.1.0.tar.gz.

File metadata

  • Download URL: fawern_nn-0.1.0.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for fawern_nn-0.1.0.tar.gz
Algorithm Hash digest
SHA256 46887f85c6c27d35eff304cd080481954e173ac08f0690158114062aa0ced2ed
MD5 7e9c5d30d4e67542167267028de0465b
BLAKE2b-256 ce9555a5d9e40a31b68eb34c7f5128191bd016bfa16b26ab5977669cd5d28f17

See more details on using hashes here.

File details

Details for the file fawern_nn-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: fawern_nn-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 6.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.7

File hashes

Hashes for fawern_nn-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 39a36120b9a2f01cc574998bae254f177871502628facd54c5abb7ea5cfe1ef0
MD5 e5cdeae33f1510b7ad4a6261bf77613f
BLAKE2b-256 3cee1ce53014730e46f128bb7351bf3147e4bce80e386e0a4c9d99e2427f8f8a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page