forked from PaddlePaddle/docs
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix 2.0 chinese doc of disable_static/enable_static/in_dynamic_mode (P…
…addlePaddle#2703) * fix 2.0 doc of disable_static/enable_static/in_dynamic_mode * fix 2.0 doc of disable_static/enable_static/in_dynamic_mode
- Loading branch information
1 parent
1a67b05
commit 7138b27
Showing
4 changed files
with
50 additions
and
91 deletions.
There are no files selected for viewing
27 changes: 16 additions & 11 deletions
27
doc/paddle/api/paddle/fluid/dygraph/base/disable_dygraph_cn.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,27 @@ | ||
.. _cn_api_fluid_disable_dygraph: | ||
.. _cn_api_paddle_enable_static: | ||
|
||
disable_dygraph | ||
enable_static | ||
------------------------------- | ||
|
||
.. py:function:: paddle.fluid.disable_dygraph() | ||
.. py:function:: paddle.enable_static() | ||
.. note:: | ||
从2.0.0版本开始,Paddle默认开启动态图模式。 | ||
|
||
该接口开启静态图模式。可通过 :ref:`cn_api_paddle_disable_static` 关闭静态图模式。 | ||
|
||
该接口关闭动态图模式。 | ||
|
||
返回:无 | ||
|
||
**示例代码** | ||
**代码示例** | ||
|
||
.. code-block:: python | ||
import paddle.fluid as fluid | ||
import numpy as np | ||
fluid.enable_dygraph() # Now we are in dygraph mode | ||
print(fluid.in_dygraph_mode()) # True | ||
fluid.disable_dygraph() | ||
print(fluid.in_dygraph_mode()) # False | ||
import paddle | ||
print(paddle.in_dynamic_mode()) # True, dynamic mode is turn ON by default since paddle 2.0.0 | ||
paddle.enable_static() | ||
print(paddle.in_dynamic_mode()) # False, Now we are in static mode | ||
paddle.disable_static() | ||
print(paddle.in_dynamic_mode()) # True, Now we are in dynamic mode |
30 changes: 18 additions & 12 deletions
30
doc/paddle/api/paddle/fluid/dygraph/base/enable_dygraph_cn.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,25 +1,31 @@ | ||
.. _cn_api_fluid_enable_dygraph: | ||
.. _cn_api_paddle_disable_static: | ||
|
||
enable_dygraph | ||
disable_static | ||
------------------------------- | ||
|
||
.. py:function:: paddle.fluid.enable_dygraph(place=None) | ||
.. py:function:: paddle.disable_static(place=None) | ||
.. note:: | ||
从2.0.0版本开始,Paddle默认开启动态图模式。 | ||
|
||
该接口关闭静态图模式。可通过 :ref:`cn_api_paddle_enable_static` 开启静态图模式。 | ||
|
||
该接口打开动态图模式。 | ||
|
||
参数: | ||
- **place** (fluid.CPUPlace 或 fluid.CUDAPlace,可选) - 执行动态图的设备数目。若为None,则设备根据paddle的编译方式决定。默认值为 ``None``。 | ||
- **place** (paddle.CPUPlace|paddle.CUDAPlace,可选) - 动态图运行时的设备。默认值为 ``None`` , 此时,会根据paddle的版本自动判断。 | ||
|
||
返回:无 | ||
|
||
**示例代码** | ||
**代码示例** | ||
|
||
.. code-block:: python | ||
import paddle.fluid as fluid | ||
import numpy as np | ||
fluid.enable_dygraph() # Now we are in dygraph mode | ||
print(fluid.in_dygraph_mode()) # True | ||
fluid.disable_dygraph() | ||
print(fluid.in_dygraph_mode()) # False | ||
import paddle | ||
print(paddle.in_dynamic_mode()) # True, dynamic mode is turn ON by default since paddle 2.0.0 | ||
paddle.enable_static() | ||
print(paddle.in_dynamic_mode()) # False, Now we are in static mode | ||
paddle.disable_static() | ||
print(paddle.in_dynamic_mode()) # True, Now we are in dynamic modes | ||
55 changes: 0 additions & 55 deletions
55
doc/paddle/api/paddle/fluid/dygraph/base/to_variable_cn.rst
This file was deleted.
Oops, something went wrong.
29 changes: 16 additions & 13 deletions
29
doc/paddle/api/paddle/fluid/framework/in_dygraph_mode_cn.rst
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,29 +1,32 @@ | ||
.. _cn_api_fluid_in_dygraph_mode: | ||
.. _cn_api_paddle_in_dynamic_mode: | ||
|
||
in_dygraph_mode | ||
in_dynamic_mode | ||
------------------------------- | ||
|
||
.. py:function:: paddle.fluid.in_dygraph_mode() | ||
.. py:function:: paddle.in_dynamic_mode() | ||
.. note:: | ||
从2.0.0版本开始,Paddle默认开启动态图模式。 | ||
|
||
该接口查看paddle当前是否在动态图模式中运行。 | ||
|
||
可以通过 :ref:`cn_api_paddle_enable_static` 开启静态图模式, :ref:`cn_api_paddle_disable_static` 关闭静态图模式。 | ||
|
||
该接口检查程序是否在动态图模式中运行。 | ||
可以通过 ``fluid.dygraph.guard`` 接口开启动态图模式。 | ||
|
||
返回:如果程序是在动态图模式下运行的,则返回 ``True``。 | ||
返回:如果paddle当前是在动态图模式运行,则返回 ``True`` ,否则返回 ``False`` | ||
|
||
返回类型:bool | ||
|
||
**示例代码** | ||
**代码示例** | ||
|
||
.. code-block:: python | ||
import paddle.fluid as fluid | ||
import paddle | ||
print(paddle.in_dynamic_mode()) # True, dynamic mode is turn ON by default since paddle 2.0.0 | ||
paddle.enable_static() | ||
print(paddle.in_dynamic_mode()) # False, Now we are in static mode | ||
fluid.enable_dygraph() # 现在进入 dygragh 模式 | ||
print(fluid.in_dygraph_mode()) # True | ||
fluid.disable_dygraph() | ||
print(fluid.in_dygraph_mode()) # False | ||
paddle.disable_static() | ||
print(paddle.in_dynamic_mode()) # True, Now we are in dynamic mode | ||