Skip to content

User Manual

Akos Kungl edited this page Mar 15, 2021 · 5 revisions

The user Manual describes the usage of the user-facing functionalities of the project.

Training and testing a single setup on the MNIST dataset

The training takes the configurations from the specified json file and trains a single model on the MNIST dataset. The in-between results are saved for further testing

The testing takes the saved configuration and gets the loss and classification ratio on the MNIST. Note: If the dataset is not present then the code tries download it from the database behind PyTorch.

Command for training:

python -m pseudo_backprop.experiments.train_mnist --params model_config.json

Command for testing:

python -m pseudo_backprop.experiments.test_mnist --params model_config.json

An example for the model_config.json file is:

{
    "batch_size": 20,
    "layers": [784, 1000, 1000, 10],
    "epochs": 120,
    "model_folder": "model_gen_pseudo",
    "model_type": "gen_pseudo",
    "learning_rate": 0.00005,
    "momentum": 0.0,
    "weight_decay": 0.0,
    "random_seed": 456732,
    "pinverse_recalc": 500,
    "gen_samples": 60000,
    "dataset": "mnist",
    "dataset_path": "../../../../dataset/mnist"
}
Entry Type Meaning
batch_size number size of minibatch; number of examples used per iteration
layers list of integers Number of neurons in the layers. The first layer is the input.
epochs integer Length of training. One epoch is one training on the whole training set
model_folder str, relative path folder to create the output to
model_type string The used model. See explanation below.
learning_rate float the learning rate
momentum float the momentum term in the pytorch sgd grad descent optimization
weight_decay float weight decay term with L2 regularization
random_seed int Random number seed to be set
pinverse_recalc int After how many iterations will be the (generalized) pseudoinverse recalculated
gen_samples integer how many examples are used for calculating the generalized pseudo-inverse
dataset string Dataset to be used: mnist or cifar10
dataset_path string, relative path path to the dataset, if not found it will be downloaded

The potential entries for the model_type are:

  • backprop: the standard backpropagation algorithm.
  • fa : feedback alignment following to Lillicrap et al. (2016). The backward weights are drawn from the same probability distribution as the forward weights.
  • pseudo_backprop : Pseudobackprop algorithm. The backward weights are set as the Moore-Penrose Pseudoinverse.
  • gen_pseudo : Generalized pseudobackprop algorithm. The backward weights are set as the generalized pseudoinverse of the forward weights.

The pinverse_recalc is only applicable for the pseudo backrpop and the generalized pseudobackprop algorithm, otherwise they are ignored. The gen_samples is only applicable for the generalized pseudoinverse algorithm, otherwise it is ignored.

Settings for the repeated experiments

An example for the master/exp_control.json is:

{
    "random_seed": 229892,
    "seed_start": 452391,
    "repetitions": 10,
    "simulator": "css",
    "test_per_images": 60000
}

The parameters are:

Entry Type Meaning
random_seed number random seed for generating the random seeds of the single repetitions
seed_start number Starting point for the seed of the single repetitions. Random numbers are added to this to generate the further seeds.
repetitions integer Length of training. One epoch is one training on the whole training set
simulator string name of the simulator. See below
test_per_images number Sets how often the tests will be executed after the training has finished. E.g. here after every 60000 images

The potential simulator parameters are:

  • direct: The simulation is started in the same environment as a subprocess as the outer command
  • css: The simulations is started using the master/slurm_script.sh as a starting slurm script
Clone this wiki locally