To train a net first load the data. The code expects input data to be divided into minibatches. Each minibatch is a matrix with each row being an image. Pixels values are in the range 0 to 1. The corresponding target values for minibatch are a matrix with rows consisting of nine zeros and a single 1. The training data and targets are called batchdata and batchtargets. The validation data and targets are called validbatchdata and validbatchtargets. The final test data and targets are called testbatchdata and testbatchtargets. Loading mnistdata.mat will create these 6 data variables. The required code is ffnew.m ffnormrows.m ffenergytest.m ffsoftmaxtest.m rms.m These are all in ffcode.zip To train a net, first set the undeclared global variables maxepoch = 100; % or some similar value restart=1; then type ffnew; It will print out the training and validation errors as it runs. At the end it will print out the errors on the official MNIST test set. Comment this code out if you plan to search for better hyperparameters. To change the size of the net, change the variable layernums in the file ffnew.m. For reasonable sized nets, you should not need to change any of the hyperparameters. The performance is slightly worse than reported in my paper where there were more hyperparameters and they were tuned for a particular net size.