GithubHelp home page GithubHelp logo

mohamed-512 / flexible_neural_net Goto Github PK

View Code? Open in Web Editor NEW
2.0 2.0 3.0 12.15 MB

A simple and flexible python library that allows you to build custom Neural Networks where you can easily tweak parameters to change how your network behaves

Python 96.92% C++ 1.07% C 1.91% Fortran 0.08% PowerShell 0.01% Batchfile 0.01%
machine-learning python3 neural-network neural-networks artificial-neural-networks ai nn python flexible easy-to-use lightweight

flexible_neural_net's Introduction

#Contributers Are Welcome ๐Ÿ‘ฉโ€๐Ÿ’ป๐Ÿ‘จโ€๐Ÿ’ป

Flexible_Neural_Net

A simple and flexible python library that allows you to build custom Neural Networks where you can easily tweak parameters to change how your network behaves

Installation

๐ŸŽ‰ Downloads ๐ŸŽ‰

pip install flexible-neural-network

Initialization

  • First initialize a Neural Net object and pass number of inputs, outputs, and hidden layers

    myNN = NeuralNet(number_of_inputs, number_of_outputs, number_of_hidden_layers)

  • You can choose how what activation function to use from: "relu", "sigmoid, "tanh"

    myNN = NeuralNet(number_of_inputs, number_of_outputs, number_of_hidden_layers, activation_func="sigmoid")

  • You can choose modify the learning rate

    myNN = NeuralNet(number_of_inputs, number_of_outputs, number_of_hidden_layers, learning_rate=0.1)

  • You can choose tweak the number of nodes in each hidden layer

    • by assigning an integer number such as 3: if there was 4 hidden layers then each layer will have 3 nodes => [3, 3, 3, 3]

      myNN = NeuralNet(number_of_inputs, number_of_outputs, number_of_hidden_layers, nodes_in_each_layer=3)

    • by assigning a list of integers number such as [3, 5, 2, 3] that has a length of number_of_hidden_layers: if there was 4 hidden layers then each layer will have different number of nodes nodes correspondingly => [3, 5, 2, 3]

      myNN = NeuralNet(number_of_inputs, number_of_outputs, number_of_hidden_layers, nodes_in_each_layer=[3, 5, 2, 3])

How to use

Assuming you initialized your object and data as below:

myNN = NeuralNet(2, 1, 2, nodes_in_each_layer=4, learning_rate=0.1, activation_func="sigmoid")

data = np.array([
        [3,   1.5, 1],
        [2,   1,   0],
        [4,   1.5, 1],
        [3,   1,   0],
        [3.5, .5,  1],
        [2,   .5,  0],
        [5.5,  1,  1],
        [1,    1,  0]
        ])

mystery_data = [2, 1] # should be classified as 1

You can:

Here we specified the number of epochs to be 1

  • Train single entries:
    myNN.train(data[0, 0:2], data[0, 2], epochs=1)

  • Train multiple entries myNN.train_many(data[:, 0:2], data[:, 2], epochs=1)

  • test single/multiple entries output = myNN.test(mystery_flower) where output is always an np.ndarray with size as the specfied in the object's constructor. for the current example it's = [1.45327823]

  • Save NN for later myNN.save("file_name")

  • Load NN without the need for retraining myNN = NeuralNet.load("file_name")

Obviously NNs do not give exact answers and its our job to determine which class is it belongs to and judging from the training data we only have class 0, or 1 and the output we got is nearer to 1 than 0 so we should classify it as 1

flexible_neural_net's People

Contributors

mohamed-512 avatar

Stargazers

Ariffudin avatar myrccar  avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.