Restore - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

Online Help

All Products    Maple    MapleSim


DeepLearning

  

Restore

  

restore model or session from file

  

Save

  

save model or session to file

 

Calling Sequence

Parameters

Options

Description

Details

Examples

Compatibility

Calling Sequence

Restore(path)

Save(path,opts)

Save(path,model,opts)

Parameters

path

-

string; path to saved state

model

-

Model object

opts

-

(optional) equations of the form format=name

Options

• 

format=one of auto, checkpoint, checkpoint[legacy], hdf5, json, or savedmodel

  

Specifies the file format to use when saving. Note that all formats other than checkpoint[legacy] require that a Model object be supplied as an argument to Save.

• 

checkpoint is a TensorFlow training checkpoint file. Currently this is identical to checkpoint[legacy] but a future version may support TensorFlow version 2 checkpoint files.

• 

checkpoint[legacy] is a TensorFlow version 1 checkpoint file.

• 

hd5 is an HDF5 (Hierarchical Data Format) file.

• 

json is a JSON file.

• 

savedmodel is a TensorFlow Keras SavedModel file.

  

The default is auto, which attempts to infer the desired format from path and which falls back to savedmodel if no other format can be inferred.

Description

• 

Restore(path) command loads a saved Model or computation session to memory from a file or directory located at path. If path corresponds to a Model, a corresponding Model object is returned. If path corresponds to a session, its state is copied into the current session.

• 

Save(path) command saves a Model or computation session in memory to a file or directory located at path.

• 

These functions are part of the DeepLearning package, so they can be used in the short form Restore(..) and Save(..) only after executing the command with(DeepLearning). However, they can always be accessed through the long form of the command by using DeepLearning[Restore](..) or DeepLearning[Save](..).

Details

• 

For more information about saving models, see the TensorFlow Python API documentation for saved models.

Examples

withDeepLearning:

Build a model and then save it to a directory in the SavedModel format.

dataImportdatasets/pima-epidemiology-diabetes.csv,base=datadir1..600,..

modelSequentialDenseLayer12,activation=relu,DenseLayer8,activation=relu,DenseLayer1,activation=sigmoid

modelDeepLearning Model<keras.src.engine.sequential.Sequential object at 0x7f82af1ed8d0>

(1)

model:-Compileloss=binary_crossentropy&comma;optimizer=adam&comma;metrics=accuracy

model:-Fitdata..,1..8&comma;dataOutcome&comma;epochs=150&comma;batchsize=10&colon;

Save/tmp/mymodel&comma;model

Save the previous model to a file in HDF5 format and restore from it.

Save/tmp/mymodel.h5&comma;model

Restore/tmp/mymodel.h5

Save the previous model to a file in JSON format and restore from it.

Save/tmp/mymodel.json&comma;model

Restore/tmp/mymodel.json

Save and restore a session in the legacy checkpoint (TensorFlow version 1) format.

SetEagerExecutionfalse

vVariable1.0&comma;0.5&comma;datatype=float8

cConstant1.5&comma;3.0&comma;datatype=float8

AssignAddv&comma;c

sessGetDefaultSession

sess:-RunVariablesInitializer

Save/tmp/mySession.ckpt&comma;format=checkpointlegacy

Restore/tmp/mySession.ckpt&comma;format=checkpointlegacy

Compatibility

• 

The DeepLearning[Restore] and DeepLearning[Save] commands were introduced in Maple 2018.

• 

For more information on Maple 2018 changes, see Updates in Maple 2018.

See Also

DeepLearning Overview