Coder Social home page Coder Social logo

direct-feedback-alignment's Introduction

Direct-Feedback-Alignment

Understanding the general framework

In dfa-linear-net.ipynb, I show how a neural network without activation function can learn a linear function (multiplication by a matrix) using direct feedback alignment (DFA), as in Nøkland, 2016. There is also some theory about it.

In dfa-mnist.ipynb, I show how a neural network trained with DFA achieves very similar results to one trained with backpropagation. The architecture is very simple: one hidden layer of 800 Tanh units, sigmoid in the last layer and binary crossentropy loss.

Go to the last lines of mlp-torch-results.txt if you want to see the results of the same architecture using Torch code provided by Nøkland.

Stacking neural networks

Do networks with different feedback matrices learn different features at least in the first few steps? Apparently yes. Stacking works training a lot of weak learners on recognizing different features and using their outputs as inputs for a new model, which will learn how to combine these weak learners and give a performance boost.

In Stacking-dfa-nets folder, you have the following files. They must be executed in the following order:

  1. create_dataset.py: preprocess MNIST data loaded from Keras and save them to a Numpy file mnist.npz, ready to be used.
  2. weak-learners.py or diff-weak-learners.py: train as many weak learners as you want (NNs with one hidden layer 800 Tanh units). The difference between the first and the second is that the first trains all of them starting from the same initialization, while the second initializes each one of them in a different state. They generate respectively files called: train_linouts.npz & test_linouts.npz, diff-train_linouts.npz & diff-test_linouts.npz
  3. stacked-model.py or RD-stacked-model.py: train respectively a dense or an RD layer on top of the features extracted by each weak learner. The program takes as input the names of the files generated by the previous steps and the number of weak learners given in the previous step.

Example call to train 50 weak learners:

python weak_learners.py 50

Example call to train a stacked model on top of 50 weak learners:

python weak_learners.py 50 train_linouts.npz test_linouts.npz

RD Layers

Layers with a linear number of parameters vaguely inspired by ACDC. Basically they do these operations:

Equation

where D1 and D2 are diagonal matrices and R is a random matrix.

Requirements

  • numpy
  • matplotlib
  • scipy
  • keras
  • scikit-learn

direct-feedback-alignment's People

Contributors

iacolippo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

direct-feedback-alignment's Issues

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.