Reusing your models
The training of neural networks can be a time-consuming process, so we need to track its progress as the process goes on. We need to learn to save and reload a trained model.
Every MXNet model consist of at least two files:
model_name-symbol.json
: Describes the architecturemodel_name-epoch.params
: Describes the model weights
You can create them yourself or you can download them from the internet. We will cover the process of using pretrained networks in the next chapter.
Saving the model
Saving the model during the training process is done using the mx.do_checkpoint
callback. A few important parameters are as follows:
- prefix: This defines the prefix of the filenames to save the model
- frequency: The frequency is measured in epochs to save checkpoints
Let's move back to the MNIST example we have been working on and adjust the mx.fit
function to include mx.do_checkpoint
:
mx.fit(nnet, mx.ADAM(), train_data_provider, eval_data = validation_data_provider, n_epoch = 50, callbacks = ...