load_dygraph

api_attr

imperative programming (dynamic graph)

paddle.fluid.dygraph.load_dygraph(model_path, keep_name_table=False)[source]

Load parameter state_dict from disk.

Parameters
  • model_path (str) – The file prefix store the state_dict. (The path should Not contain suffix ‘.pdparams’)

  • keep_name_table (bool, optional) – Whether keep structed name to parameter name conversion table in output dict. Default : False

Returns

the dict store the state_dict

Return type

state_dict(dict)

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")

    para_state_dict, opti_state_dict = fluid.load_dygraph( "paddle_dy")