save_dygraph¶
- paddle.fluid.dygraph.checkpoint. save_dygraph ( state_dict, model_path ) [source]
-
- Api_attr
-
imperative
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([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), parameter_list = emb.parameters() ) state_dict = adam.state_dict() fluid.save_dygraph( state_dict, "paddle_dy")