中文注释版 of forward-forward (FF) training algorithm - an alternative to back-propagation
原理可以参考中文翻译:
https://www.163.com/dy/article/HNLP6E5N0511831M.html
详细注释,请看 main.py 文件,本仓库fork于 https://github.com/mohammadpz/pytorch_forward_forward 感谢他们的付出,so cool !!!
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
A negative sample
Among the many ways of generating the positive/negative samples, for MNIST, we have:
Positive sample
Negative sample
After training all the layers, to make a prediction for a test image
With this implementation, the training and test accuracy on MNIST are:
> python main.py
train error: 0.06754004955291748
test error: 0.06840002536773682