diff --git a/doc/fluid/beginners_guide/coding_practice/save_load_variables_en.rst b/doc/fluid/beginners_guide/coding_practice/save_load_variables_en.rst index 627bdb2191dbe76babd65c76c32e5ee3cbab32bb..2471ccfdf4607df5dc2591d99f6186949923fee9 100644 --- a/doc/fluid/beginners_guide/coding_practice/save_load_variables_en.rst +++ b/doc/fluid/beginners_guide/coding_practice/save_load_variables_en.rst @@ -27,6 +27,23 @@ How to save model variables The model variables we need to save are different depending on the application. For example, if we just want to save the model for future predictions, just saving the model parameters will be enough. But if we need to save a checkpoint for future recovery of current training, then we should save all the persistable variables, and even record the current epoch and step id. It is because even though some model variables are not parameters, they are still essential for model training. + +Difference between save_vars、save_params、save_persistables and save_inference_model +########################################################################## +1. :code:`save_inference_model` will prune the inference model based on :code:`feeded_var_names` and :code:`target_vars` , this method will save the ``__model__`` file of the pruned program and the persistable variables in the program. + +2. :code:`save_persistables` this method will not save model, it will save all the persistable variables in the program. + +3. :code:`save_params` this method will not save model, it will save all the parameters in the program. + +4. :code:`save_vars` this method will not save model, it will save the given parameter by user. + + :code:`save_persistables` this method is useful for increment training or checkpoint training, it can save persistable variables in program comprehensively, such as parameter variables, optimizer variables, if you need increment training or checkpoint training, please choose this one. + :code:`save_inference_model` this method is useful for inference, it will save persistable variables and pruned program, if you need program and variables for follow-up high performance inference, please choose this one. + + :code:`save_vars 和 save_params` there methods are only needed in particular cases, we suppose you already know the purpose of there APIs, there are not recommended for use normally. + + Save the model to make prediction for new samples ===================================================