paddle.fluid.io. load_params ( executor, dirname, main_program=None, filename=None ) [source]

Static Graph

This API filters out all parameters from the give main_program and then tries to load these parameters from the directory dirname or the file filename.

Use the dirname to specify the directory where parameters were saved. If parameters were saved in separate files under the directory dirname, set filename as None; if all parameters were saved in a single file, use filename to specify the file name.


Some variables are not Parameter while they are necessary for training, such as learning rate, global step, etc. So you cannot save and continue your training just by using api_fluid_io_save_params and api_fluid_io_load_params. Please use api_fluid_io_save_persistables and api_fluid_io_load_persistables instead.

If you want to load the pre-trained model structure and parameters for the inference, please use the api_fluid_io_load_inference_model API. You can refer to Save and Load a Model for more details.

  • executor (Executor) – The executor used for loading parameters. See Executor for more details about it.

  • dirname (str) – The directory path.

  • main_program (Program, optional) – The program whose parameters will be loaded. If it is None, the default_main_program will be used automatically. See Basic Concept for more about Program. Default: None.

  • filename (str, optional) – The file which saved all parameters. If parameters were saved in separated files, set it to None. Default: None.




import paddle
import paddle.fluid as fluid

exe = fluid.Executor(fluid.CPUPlace())
param_path = "./my_paddle_model"
prog = fluid.default_main_program()
fluid.io.load_params(executor=exe, dirname=param_path,