Skip to main content

Create fast, optimized, and easy-to-use neural networks.

Project description

flowa

netkw - Neural Network Toolkit

License Python Versions

netwk: (V2.12.5)

Create fast, optimized, and easy-to-use neural networks.

Installing

# Linux/macOS
python3 pip install -U netwk

# Windows
py -3 -m pip install -U netwk

FastFix:

+ Made it so for hidden layers, you can have just one layer, in or not in a list/tuple.

Usage

import netwk as nk

nk.Seed(52) # Optional, used for testing purposes.

x = nk.Array([[0, 0], [0, 1], [1, 0], [1, 1]])
y = nk.Array([[0], [1], [1], [0]])
network = nk.Network(
    nk.Input(2),
    (
        nk.Hidden(3, nk.Tanh), 
        nk.Hidden(2, nk.Sigmoid)
    ),
    nk.Output(1)
)
network.train(x, y, epoch=500)
print(network.predict(x)
/* Output (800ms Average):
>>> Epoch: 0, Error: 0.4984800733120248
>>> Epoch: 50, Error: 0.49632395442760113
>>> Epoch: 100, Error: 0.4781823668945816
>>> Epoch: 150, Error: 0.35665153383154413
>>> Epoch: 200, Error: 0.1874969659672475
>>> Epoch: 250, Error: 0.12789399797698137
>>> Epoch: 300, Error: 0.10069853802998781
>>> Epoch: 350, Error: 0.08495289503359527
>>> Epoch: 400, Error: 0.07452557528756484
>>> Epoch: 450, Error: 0.06702276126613768
[[0.10447174]
 [0.94106133]
 [0.94096653]
 [0.02281434]]
*/

All activations:

/*
    "Sigmoid",
    "Tanh",
    "ReLU",
    "LeakyReLU",
    "ELU",
    "Swish",
    "Gaussion",
    "Identity",
    "BinaryStep",
    "PReLU",
    "Exponential",
    "Softplus",
    "Softsign",
    "BentIdentity",
    "ArcTan",
    "SiLU",
    "Mish",
    "HardSigmoid",
    "HardTanh",
    "SoftExponential",
    "ISRU",
    "Sine",
    "Cosine",
    "SQNL",
    "SoftClipping",
    "BentIdentity2",
    "LogLog",
    "GELU",
    "Softmin",
*/

Make your own!

import netwk as nk

class MyModule(nk.Module):
    def __init__(self, *args, **kwargs):
        super().__init__("MyModule", *args, **kwargs)

    def forward(self, x):
        return x

    def backward(self, x, y, outputs):
        return nk.np.ones_like(x)

Seeing used modules + seed.

import netwk as nk

...Defining A Neural Network Here...

print(nk.modules())
/* Example:
{'Input': Input(size: 2), 'Hidden': Hidden(size: 2), 'Output': Output(size: 1), 'Network': Network(
    Input Layer:
        1 Input(size: 2)

    Hidden Layers:        
        1 Hidden(size: 3)
        2 Hidden(size: 2)

    Output Layer:
        1 Output(size: 1)
)}
*/
print(nk.seed())
# print(nk.seed(34))
/* Example:
0
# 34
*/

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

netwk-2.12.5.tar.gz (6.3 kB view hashes)

Uploaded Source

Built Distribution

netwk-2.12.5-py3-none-any.whl (7.3 kB view hashes)

Uploaded Python 3

Supported by

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