cavis/docs/deeplearning4j-nn/templates/model-persistence.md

1.2 KiB

title short_title description category weight
Deeplearning4j Model Persistence Model Persistence Saving and loading of neural networks. Models 10

Saving and Loading a Neural Network

The ModelSerializer is a class which handles loading and saving models. There are two methods for saving models shown in the examples through the link. The first example saves a normal multilayer network, the second one saves a computation graph.

Here is a basic example with code to save a computation graph using the ModelSerializer class, as well as 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 may make 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.

Model serializer

{{autogenerated}}