GithubHelp home page GithubHelp logo

lforksl / pure-numpy-feedfowardnn Goto Github PK

View Code? Open in Web Editor NEW

This project forked from ludobouan/pure-numpy-feedfowardnn

0.0 1.0 0.0 313 KB

Simple feedforward neural network class written in pure python+numpy

Python 2.85% Jupyter Notebook 97.15%

pure-numpy-feedfowardnn's Introduction

pure-numpy-feedfowardNN

Simple feedforward neural network class "handmade" in pure python+numpy
Winner of Siraj Ravel's coding challange

Characteristics

  • Fully connected feed forward neural network with as many hidden layers as needed, of any size.
  • Implements backpropagation : link 1, link 2, link 3 (does not implement gradient checking)
  • Uses gradient descent for optimization
  • Uses Sum Squared Error cost function
  • Uses the sigmoid activation function

How to use

  1. Create an instance
    nn = NeuralNetwork()
  2. Add layers
    The first input layer is created automatically
    nn.add_layer(shape=(input_dim1, output_dim1))
    nn.add_layer(shape=(input_dim2, output_dim2))
  3. Train
    nn.train(features, targets, num_epochs, learning_rate)
  4. Predict
    nn.predict(features)

The nn.train() method has an optional parameter called stop_accuracy. At the end of each epoch the mean loss is calculated and if it is under the specified threshold than the training stops. This avoids training longer than necessary. By looking at the number of epochs needed to reach the threshold, it gives us a good metric as to the performance of our hyperparameters.

Example: XOR function

The Jupyter Notebook shows how the network can be used to approximate the XOR function using a 3-layer neural network. We attempt to find the optimal network dimensions and the optimal learning rate.

Error Optimization

Dependencies

  • Numpy

pure-numpy-feedfowardnn's People

Contributors

ludobouan avatar

Watchers

 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.