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()
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
Release history Release notifications | RSS feed
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)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46887f85c6c27d35eff304cd080481954e173ac08f0690158114062aa0ced2ed
|
|
| MD5 |
7e9c5d30d4e67542167267028de0465b
|
|
| BLAKE2b-256 |
ce9555a5d9e40a31b68eb34c7f5128191bd016bfa16b26ab5977669cd5d28f17
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
39a36120b9a2f01cc574998bae254f177871502628facd54c5abb7ea5cfe1ef0
|
|
| MD5 |
e5cdeae33f1510b7ad4a6261bf77613f
|
|
| BLAKE2b-256 |
3cee1ce53014730e46f128bb7351bf3147e4bce80e386e0a4c9d99e2427f8f8a
|