This repository contains the source code related to the paper "On the Road with 16 Neurons: Mental Imagery with Bio-inspired Deep Neural Networks". The code is written in Keras using TensorFlow backend.
README.mdthis file.cnfg/configuration files.dataset/structure of folders containing all data used to train the models.imgs/some visual predictions resulted from different experiments.log/collection of significant saved trained neural models, and summary tables.math/various Mathematica scripts for recreation of neural models and visualization.models/state-of-the-art pretrained models (like VGG16).res/folder where executions are automatically saved.src/Python scripts:arch.pydefines the architectures of neural models,cnfg.pyhandles command line arguments,exec_dset.pycreates the structures of symlinks for building a dataset,exec_eval.pyloads and evaluates a saved model,exec_feat.pygenerates dataset of latent space encodings,exec_lata.pyis a collection of functions to analyze the latent space,exec_main.pyis the main file to execute training,gener.pyhandles the Generator structures for parsing a dataset,h5lib.pyis a collection of utilities for loading weights from an HDF5 file,mesg.pycontains utilities for printing error messages,pred.pydefines a class for non-neural time prediction,sample_sel.pycontains a dictionary of manually-selected samples of different type of events,tester.pycollects functions for testing a trained model,trainer.pycontains the training routine.
video/animations showing the best results.
To run the program, execute the main script src/exec_main.py . The script supports the following command line arguments:
exec_main.py [-h] -c <file> -g <num> [-f <frac>] [-l <model>] [-Ttrsaex]
-a,--accurexecute accuracy evaluation on selected samples (-a) or on all test set (-aa) (it may take a while!).-c <file>,--config <file>pass a configuration file describing the model architecture and training parameters.-e,--evalexecute evaluation routines.-f <frac>,--fgpu <frac>set the fraction of GPU memory to allocate [default: 0.90].-g <num>,--gpu <num>set the number of GPUs to use (0 if CPU) or list of GPU indices.-h,--helpshow the help message with description of the arguments.-i,--intrpexecute interpolation tests.-l <model>,--load <model>pass a folder or a HDF5 file to load as weights or entire model.-p,--predcompute model predictions over a selected set of images.-r,--redirredirect stderr and stdout to log files.-s,--savearchive configuration file (-s) and python scripts (-ss) used.-t,--testexecute testing routines.-T,--trainexecute training of the model.-x,--hallxexecute hallucination routines.
As example, run the following command from the upmost autoencoder/ folder. This command will train a new model on the first two GPUs on the machine. Then it will test the results, save all the files required to reproduce the experiment, and redirect all console messages to log files:
$ python src/exec_main.py -c config/cnfg_file -g 0,1 -Ttssr
Another example, this command will load an already trained model and will execute all the test routines on CPU:
$ python src/exec_main.py -l log/nicemodel/nn_best.h5 -c log/nicemodel/config/cnfg_file -g 0 -taaeipx
