This project was the base of my Bachelor's Thesis, mentored by Professor Reinhold von Schwerin and Professor Ronald Blechschmidt, during my stay at the Technische Hochschule Ulm.
This repository contrains an implementation of the paper An Approximation of the Error Backpropagation Algorithm in a Predictive Coding Network with Local Hebbian Synaptic Plasticity, Whittington, James CR and Bogacz, Rafal [2017] - link.
Predictive Coding is an alternative approach to artificial neural networks, inspired by theories of brain function. The network is structured in a hierarchical fashion with multiple layers (similar to deep learning), in which bottom-most layers receive sensory input, while the higher layers are responsible for representing the underlying hidden causes of such inputs (i.e. the inferred structure of the real world which gave rise to such input, i.e. explain the input).
Meanwhile, top-bottom (feedback) connections generate the predicted input given the hidden causes encoded in the higher layers, which are then compared with the actual input. Finally, their difference (the prediction error) is transmitted through bottom-up (forward) connections, adjusting the actual valued of the hidden causes such that they better explain the sensory information.
There are many flavors of the Predictive Coding framework, and one in particular is a simple classifier for a static input network (that is, the input data does not contain a temporal dimension).
We compare the performance of a typical Backprop network againt the Predictive Coding implementation, on the Imagenet dataset.
Run all the commands below from the root folder
-
Download the
Train(64x64) part1
,Train(64x64) part2
andVal(64x64)
(selectnpz format
) from the imagenet website. Extract insidedatasets/imagenet-64x64/
. -
(optional) Create subsampled dataset (select desired class indices modifying
DESIRED_CLASSES
in the filereduce-dataset.py
) and then
python datasets/imagenet-64x64-reduced/reduce-dataset.py
-
Update the variable
NUM_CLASSES
inexamples/imagenet-64x64.py
to match the number of classes selected on previous step -
Train the backpropagation + predictive coding networks
python -W ignore examples/imagenet-64x64.py
-
Download the entire ImageNet dataset (from somewhere) and update the variable
FOLDER
in the fileexamples/imagenet-224x224.py
to match the location of the dataset. -
(optional) Select only some folders of some classes from the dataset, and put them inside the folder
datasets/imagenet-reduced/train/
anddatasets/imagenet-reduced/val/
. -
Train the backpropagation + predictive coding networks
python -W ignore examples/imagenet-224x224.py
- For 50 classes:
./experiments/ImageNet_50_classes_224x224/run.bash | tee -a results/ImageNet_50_classes_224x224/log.txt
- Or, using
tmux
:
tmux
./experiments/ImageNet_50_classes_224x224/run.bash | tee -a results/ImageNet_50_classes_224x224/log.txt
Detach from session with Ctrl+B
and then D
- To reattach after logging off:
tmux attach