Skip to content

Simple feed forward neural network with back propagation learning algorithm

License

Notifications You must be signed in to change notification settings

YuriyLisovskiy/NeuralNetwork

Repository files navigation

NeuralNetwork

License Language AppVeyor Travis CI Coveralls
PyPi PyPI Build status Build Status Coverage Status

Installation

Linux:

$ git clone https://github.com/YuriyLisovskiy/NeuralNetwork.git
$ cd NeuralNetwork/
$ virtualenv venv
$ source venv/bin/activate
$ pip install -r requirements.txt

Windows:

$ git clone https://github.com/YuriyLisovskiy/NeuralNetwork.git
$ cd NeuralNetwork/
$ virtualenv venv
$ venv/Scripts/activate
$ pip install -r requirements.txt

Run demo:

$ python runner.py test

Usage

  • From neural_network package import network:
     from neural_network.network.net import NeuralNetwork
  • Create training data for training neural network, example:
     training_data = [
         ([0, 0, 0], 0),
         ([0, 0, 1], 1),
         ([0, 1, 0], 0),
         ([0, 1, 1], 0),
         ([1, 0, 0], 1),
         ([1, 0, 1], 1),
         ([1, 1, 0], 0),
         ([1, 1, 1], 1)
     ]
  • Create new neural network using config/config.py or custom parameters, example:
     INPUT_LAYER = [3]
     HIDDEN_LAYERS = [5, 4, 2]
     OUTPUT_LAYER = [1]
     ITERATIONS = 10000
     LEARNING_RATE = 0.007
     new_net = NeuralNetwork(
         input_layer=INPUT_LAYER,
         hidden_layers=HIDDEN_LAYERS,
         output_layer=OUTPUT_LAYER,
         learning_rate=LEARNING_RATE,
         log=False
     )
  • Train the network:
     new_net.train(
         data=training_data,
         iterations=ITERATIONS,
         log=False
     )
  • Now network is ready to work, example:
     def get_prediction(input_data):
         result = new_net.predict(input_data)
         return result >= 0.5
     if __name__ == '__main__':
         print(get_prediction([0, 1, 0]))

Author

License

This project is licensed under the BSD-2-Clause License - see the LICENSE file for details.

About

Simple feed forward neural network with back propagation learning algorithm

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages