matlabneural-networknntool

Is it necessary to initialized the weights for every time retraining the same model in matlab with nntool?


I know for the ANN model, the initial weights are random. If I train a model and repeat training 10 times by nntool, do the weights initialize every time when I click the training button, or still use the same initial weights you just adjusted?


Solution

  • I am not sure if the nntool you refer to uses the train method (see here https://de.mathworks.com/help/nnet/ref/train.html).

    I have used this method quite extensively and it works in a similar way as tensorflow, you store a number of checkpoints and load the latest status to continue training from such point. The code would look something like this.

    [feat,target] = iris_dataset;
    my_nn = patternnet(20);
    my_nn = train(my_nn,feat,target,'CheckpointFile','MyCheckpoint','CheckpointDelay',30);
    

    Here we have requested that checkpoints are stored at a rate not greater than one each 30 seconds. When you want to continue training the net must be loaded from the checkpoint file as:

    [feat,target] = iris_dataset;
    load MyCheckpoint
    my_nn = checkpoint.my_nn;
    my_nn = train(my_nn,feat,target,'CheckpointFile','MyCheckpoint');
    

    This solution involves training the network from the command line or via a script rather than using the GUI supplied by Mathworks. I honestly think this latter method is great for beginners but if you want to do any interesting clever start using the command line or even better switch to libraries like Torch or Tensorflow!

    Hope it helps!