Attend a 3-Day Introductory Deep Learning Workshop View Upcoming Workshops »

Saving and Loading a Neural Network

The ModelSerializer is a class which handles loading and saving models. There are 2 methods for saving (in the examples below) The first example saves a normal multi layer network, the second one saves a computation graph

Here is a basic Example that provides the code to save a computation graph using the ModelSerializer class, and also an example of using ModelSerializer to save a Neural Net built using MultiLayer Configuration.

RNG Seed

If your model uses probabilities (i.e. DropOut/DropConnect), it might have sense to save it separately, and apply it after model is restored. I.e:

 Nd4j.getRandom().setSeed(12345);
 ModelSerializer.restoreMultiLayerNetwork(modelFile);

This will guarantee equal results between sessions/JVMs.

Chat with us on Gitter