GithubHelp home page GithubHelp logo

danyray420 / pytorch_forward_forward Goto Github PK

View Code? Open in Web Editor NEW

This project forked from mpezeshki/pytorch_forward_forward

0.0 0.0 0.0 226 KB

Implementation of Hinton's forward-forward (FF) algorithm - an alternative to back-propagation

License: MIT License

Python 100.00%

pytorch_forward_forward's Introduction

pytorch_forward_forward

Implementation of forward-forward (FF) training algorithm - an alternative to back-propagation

Below is my understanding of the FF algorithm presented at Geoffrey Hinton's talk at NeurIPS 2022.
The conventional backprop computes the gradients by successive applications of the chain rule, from the objective function to the parameters. FF, however, computes the gradients locally with a local objective function, so there is no need to backpropagate the errors.

The local objective function is designed to push a layer's output to values larger than a threshold for positive samples and to values smaller than a threshold for negative samples.

A positive sample $s$ is a real datapoint with a large $P(s)$ under the training distribution.
A negative sample $s'$ is a fake datapoint with a small $P(s')$ under the training distribution.

Among the many ways of generating the positive/negative samples, for MNIST, we have:
Positive sample $s = merge(x, y)$, the image and its label
Negative sample $s' = merge(x, y_{random})$, the image and a random label

After training all the layers, to make a prediction for a test image $x$, we find the pair $s = (x, y)$ for all $0 \leq y < 10$ that maximizes the network's overall activation.

With this implementation, the training and test errors on MNIST are:

> python main.py
train error: 0.06754004955291748
test error: 0.06840002536773682

pytorch_forward_forward's People

Contributors

mpezeshki avatar haaris-rahman avatar philgineer 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.