GithubHelp home page GithubHelp logo

logicnet's Introduction

Logic Neural Network

This is a 2 hidden layer neural network made with love :)
This was original made for learning logical gates but you can use with any normalized data.

Requirements

git clone https://github.com/manoloesparta/logicnet
pip install -r requirements.txt

Usage

Instance of a neural network

from neuralnetwork import NeuralNetwork

input_nodes = 2
hidden_layer1_nodes = 100
hidden_layer2_nodes = 100
output_nodes = 1
learning_rate = 0.3

ann = NeuralNetwork(input_nodes, hidden_layer1_nodes, hidden_layer2_nodes, output_nodes, learning_rate)

Creating the data for the neural network

NOTE: The only data it creates is about logical gates using the functions AND or OR. If you want to use your own data, you need to your normalize data and feed it to the network

from data import DataGenerator

num_samples = 100

data =  DataGenerator(num_samples).logic_data()
x = data['train_data']
y = data['target_data']

Training neural network

epochs = 1000

ann.train(x, y, epochs)

Predicting

unknown_answer = [[0,1]]

ann.predict(unknown_answer)

Saving and loading weights

Saving Weights

When a full training is complete automatically weights are saved in:

./src/weights/

Loading Weights

You can use this method without and instance of the class, and create the full neural network so you can start predicting

from neuralnetwork import NeuralNetwork

ann = NeuralNetwork.load_weights()
ann.predict([[0,1]])

Dokcer

In order to build your docker image use the command

docker build -t ann .

Finally in order to run your container use

docker run --rm -v $(pwd):/usr/src/ -it ann bash

License

This project is licensed under the MIT License

logicnet's People

Contributors

manoloesparta avatar dependabot[bot] avatar

Stargazers

Roman avatar Yang Wang  avatar Gerardo Hernández  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.