Skip to content

Commit

Permalink
Remove SaveLoadConfig and polish save load cn doc (PaddlePaddle#2769)
Browse files Browse the repository at this point in the history
* remove SaveLoadConfig & polish api doc

* update images for polishing guide doc later

* polish details

* enable_static for static example

* update fc argument use case

* update fc argument activation
  • Loading branch information
chenwhql authored Oct 13, 2020
1 parent b85b05f commit c20dc16
Show file tree
Hide file tree
Showing 13 changed files with 96 additions and 583 deletions.
1 change: 0 additions & 1 deletion doc/paddle/api/alias_api_mapping
Original file line number Diff line number Diff line change
Expand Up @@ -407,7 +407,6 @@ paddle.nn.layer.common.Embedding paddle.nn.Embedding,paddle.nn.layer.Embedding
paddle.tensor.math.isnan paddle.isnan,paddle.tensor.isnan
paddle.nn.functional.loss.kl_div paddle.nn.functional.kl_div
paddle.tensor.manipulation.expand paddle.expand,paddle.tensor.expand
paddle.fluid.dygraph.jit.SaveLoadConfig paddle.SaveLoadConfig,paddle.framework.SaveLoadConfig
paddle.nn.functional.common.dropout paddle.nn.functional.dropout
paddle.nn.functional.common.linear paddle.nn.functional.linear
paddle.nn.layer.activation.LogSoftmax paddle.nn.LogSoftmax,paddle.nn.layer.LogSoftmax
Expand Down
2 changes: 0 additions & 2 deletions doc/paddle/api/api_label
Original file line number Diff line number Diff line change
Expand Up @@ -725,7 +725,6 @@ Swish .. _api_paddle_nn_layer_activation_Swish:
QueueDataset .. _api_paddle_fluid_dataset_QueueDataset:
train .. _api_paddle_dataset_movielens_train:
reciprocal .. _api_paddle_fluid_layers_reciprocal:
SaveLoadConfig .. _api_paddle_jit_SaveLoadConfig:
MetricBase .. _api_paddle_fluid_metrics_MetricBase:
adaptive_avg_pool2d .. _api_paddle_nn_functional_pooling_adaptive_avg_pool2d:
polynomial_decay .. _api_paddle_fluid_layers_polynomial_decay:
Expand Down Expand Up @@ -980,7 +979,6 @@ trace .. _api_paddle_tensor_math_trace:
set_gradient_clip .. _api_paddle_fluid_clip_set_gradient_clip:
FSTimeOut .. _api_paddle_distributed_fleet_utils_FSTimeOut:
crop_tensor .. _api_paddle_fluid_layers_crop_tensor:
load .. _api_paddle_fluid_layers_load:
program_guard .. _api_paddle_fluid_framework_program_guard:
retinanet_detection_output .. _api_paddle_fluid_layers_retinanet_detection_output:
Sampler .. _api_paddle_io_Sampler:
Expand Down
22 changes: 10 additions & 12 deletions doc/paddle/api/paddle/fluid/dygraph/checkpoint/load_dygraph_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -4,27 +4,28 @@ load
----


.. py:function:: paddle.fluid.dygraph.load_dygraph(model_path, config=None)
.. py:function:: paddle.fluid.dygraph.load_dygraph(model_path, **configs)
该接口用于从磁盘中加载Layer和Optimizer的 ``state_dict`` ,该接口会同时加载 ``model_path + ".pdparams"`` 和 ``model_path + ".pdopt"`` 中的内容。

.. note::
如果从 ``paddle.static.save_inference_model`` 的存储结果中载入 ``state_dict`` ,动态图模式下参数的结构性变量名将无法被恢复。并且在将载入的 ``state_dict`` 配置到当前Layer中时,需要配置 ``Layer.set_state_dict`` 的参数 ``use_structured_name=False`` 。

参数:
- **model_path** (str) – 保存state_dict的文件前缀。该路径不应该包括后缀 ``.pdparams`` 或 ``.pdopt``。
- **config** (SaveLoadConfig, 可选) - 用于指定额外配置选项的 :ref:`cn_api_fluid_dygraph_jit_SaveLoadConfig` 对象,这些选项主要是用于兼容 ``paddle.static.save_inference_model`` 存储模型的格式。默认为 ``None``。
参数
:::::::::
- model_path (str) – 保存state_dict的文件前缀。该路径不应该包括后缀 ``.pdparams`` 或 ``.pdopt``。
- **config (dict, 可选) - 其他用于兼容的载入配置选项。这些选项将来可能被移除,如果不是必须使用,不推荐使用这些配置选项。默认为 ``None``。目前支持以下配置选项:(1) model_filename (str) - paddle 1.x版本 ``save_inference_model`` 接口存储格式的预测模型文件名,原默认文件名为 ``__model__`` ; (2) params_filename (str) - paddle 1.x版本 ``save_inference_model`` 接口存储格式的参数文件名,没有默认文件名,默认将各个参数分散存储为单独的文件。

返回: 两个 ``dict`` ,即从文件中恢复的模型参数 ``dict`` 和优化器参数 ``dict``,如果只找到其中一个的存储文件,另一个返回None
返回
:::::::::
tuple(dict, dict),两个 ``dict`` ,即从文件中恢复的模型参数 ``dict`` 和优化器参数 ``dict``,如果只找到其中一个的存储文件,另一个返回None

- param_dict: 从文件中恢复的模型参数 ``dict``
- opt_dict: 从文件中恢复的优化器参数 ``dict``

返回类型: tuple(dict, dict)

**代码示例**
代码示例
:::::::::

.. code-block:: python
Expand All @@ -47,6 +48,3 @@ load
fluid.save_dygraph(state_dict, "paddle_dy")
para_state_dict, opti_state_dict = fluid.load_dygraph("paddle_dy")
328 changes: 0 additions & 328 deletions doc/paddle/api/paddle/fluid/dygraph/jit/SaveLoadConfig_cn.rst

This file was deleted.

Loading

0 comments on commit c20dc16

Please sign in to comment.