paddle.static. load ( program, model_path, executor=None, var_list=None ) [source]

Static Graph

This function get parameters and optimizer information from program, and then get corresponding value from file. An exception will throw if shape or dtype of the parameters is not match.

This function can also load model file saved with [ save_params, save_persistables, save_vars ]. var_list can not be None when load single model file ( filename is not None When save_params, save_persistables or save_vars is called ).

  • program (Program) – The program will be loaded

  • model_path (str) – The file prefix store the program

  • executor (Executor, optional) – The executor used for initialize the parameter When startup program is not run.

  • var_list (list|tuple, optional) – The Tensor list/tuple to load single model file saved with [ save_params, save_persistables, save_vars ]. Default: None



>>> import paddle
>>> import paddle.static as static

>>> paddle.enable_static()

>>> x = static.data(name="x", shape=[10, 10], dtype='float32')
>>> y = static.nn.fc(x, 10)
>>> z = static.nn.fc(y, 10)

>>> place = paddle.CPUPlace()
>>> exe = static.Executor(place)
>>> exe.run(static.default_startup_program())
>>> prog = static.default_main_program()

>>> static.save(prog, "./temp")
>>> static.load(prog, "./temp")