save_dygraph

paddle.fluid.dygraph.save_dygraph(state_dict, model_path)[source]

Save Layer’s state_dict to disk. This will generate a file with suffix “.pdparams”

The state_dict is get from Layers.state_dict function

Parameters
  • state_dict (dict) – The state dict to be saved.

  • model_path (str) – the file prefix to save the state_dict. The format is “dirname/file_prefix”. If file_prefix is empty str. A exception will be raised

Returns

None

Examples

import paddle.fluid as fluid

with fluid.dygraph.guard():
    emb = fluid.dygraph.Embedding( "emb", [10, 10])

    state_dict = emb.state_dict()
    fluid.save_dygraph( state_dict, "paddle_dy")

    adam = fluid.optimizer.Adam( learning_rate = fluid.layers.noam_decay( 100, 10000) )

    state_dict = adam.state_dict()
    fluid.save_dygraph( state_dict, "paddle_dy")