-
Notifications
You must be signed in to change notification settings - Fork 874
动转静概述更新 #4099
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
动转静概述更新 #4099
Conversation
update style
|
|
||
| 如下将详细地介绍动静转换的各个模块内容: | ||
| * **动态图编程:** 采用 Python 风格的编程方式,解析式的执行方式。每写一行网络代码,即可同时获得计算结果。在 | ||
| `模型开发 <../02_paddle2.0_develop/index_cn.html>`_ 章节中,介绍的都是动态图编程方式。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这里不应该手动换行?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
| ========================= | ||
|
|
||
| PaddlePaddle 在2.0版本之后,正式支持动态图转静态图(@to_static)的功能,对动态图代码进行智能化分析,自动转换为静态图网络结构,兼顾了动态图易用性和静态图部署性能两方面的优势。 | ||
| 从深度学习模型构建方式上看,飞桨框架支持动态图编程和静态图编程两种方式,其代码编写方式和执行方式均存在差异。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 从深度学习模型构建方式上看,飞桨框架支持动态图编程和静态图编程两种方式,其代码编写方式和执行方式均存在差异。 | |
| 在深度学习模型构建上,飞桨框架支持动态图编程和静态图编程两种方式,其代码编写和执行方式均存在差异。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
| 从深度学习模型构建方式上看,飞桨框架支持动态图编程和静态图编程两种方式,其代码编写方式和执行方式均存在差异。 | ||
|
|
||
| 如下将详细地介绍动静转换的各个模块内容: | ||
| * **动态图编程:** 采用 Python 风格的编程方式,解析式的执行方式。每写一行网络代码,即可同时获得计算结果。在 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * **动态图编程:** 采用 Python 风格的编程方式,解析式的执行方式。每写一行网络代码,即可同时获得计算结果。在 | |
| * **动态图编程:** 采用 Python 的编程风格,解析式地执行每一行网络代码,并同时返回计算结果。在 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
| * **动态图编程:** 采用 Python 风格的编程方式,解析式的执行方式。每写一行网络代码,即可同时获得计算结果。在 | ||
| `模型开发 <../02_paddle2.0_develop/index_cn.html>`_ 章节中,介绍的都是动态图编程方式。 | ||
|
|
||
| * **静态图编程:** 采用先编译后执行的方式。先预定义完整的神经网络结构,飞桨框架将神经网络描述为 `Program` 的数据结构,对 `Program` 进行编译优化,再调用执行器获得计算结果。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * **静态图编程:** 采用先编译后执行的方式。先预定义完整的神经网络结构,飞桨框架将神经网络描述为 `Program` 的数据结构,对 `Program` 进行编译优化,再调用执行器获得计算结果。 | |
| * **静态图编程:** 采用先编译后执行的方式。在飞桨框架中,神经网络被描述为 `Program` 的数据结构,先预定义完整的神经网络结构,并对 `Program` 进行编译优化,再调用执行器获得计算结果。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
突出体现需提前在代码中预定义完整结构,再编译优化和执行。修改描述:需先在代码中预定义完整的神经网络结构,飞桨框架会将神经网络描述为 Program 的数据结构,并对 Program 进行编译优化,再调用执行器获得计算结果。
|
|
||
| * **静态图编程:** 采用先编译后执行的方式。先预定义完整的神经网络结构,飞桨框架将神经网络描述为 `Program` 的数据结构,对 `Program` 进行编译优化,再调用执行器获得计算结果。 | ||
|
|
||
| 动态图编程体验更佳、更易调试,但是因为采用 Python 实时执行的方式,而 Python 执行开销较大,与 C++ 有一定差距,性能方面不占优。静态图调试难度大,但是将前端 Python 编写的神经网络预定义为 Program描述,转到 C++ 端重新解析执行,脱离了 Python 依赖,往往执行性能更佳,并且预先拥有完整网络结构也更利于全局优化。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 动态图编程体验更佳、更易调试,但是因为采用 Python 实时执行的方式,而 Python 执行开销较大,与 C++ 有一定差距,性能方面不占优。静态图调试难度大,但是将前端 Python 编写的神经网络预定义为 Program描述,转到 C++ 端重新解析执行,脱离了 Python 依赖,往往执行性能更佳,并且预先拥有完整网络结构也更利于全局优化。 | |
| 动态图编程体验更佳、更易调试,但是因为采用 Python 实时执行的方式,开销较大,在性能方面与 C++ 有一定差距; | |
| 静态图将前端 Python 编写的神经网络预定义为 Program描述,转到 C++ 端重新解析执行,脱离了 Python 依赖,执行性能更佳,并且预先拥有完整网络结构也更利于全局优化,但调试难度大。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
|
|
||
| * **在模型开发时,推荐采用动态图编程:** 可获得更好的编程体验、更易用的接口、更友好的调试交互机制。 | ||
|
|
||
| * **在模型训练或者推理部署时,只需添加一行装饰器 @to_static,即可将动态图代码转写为静态图代码,并在底层自动使用静态图执行器运行:** 可获得更好的模型运行性能。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| * **在模型训练或者推理部署时,只需添加一行装饰器 @to_static,即可将动态图代码转写为静态图代码,并在底层自动使用静态图执行器运行:** 可获得更好的模型运行性能。 | |
| * **在模型训练或者推理部署时,只需添加一行装饰器 @to_static,即可将动态图代码转写为静态图代码,并在底层自动使用静态图执行器运行,** 可获得更好的模型运行性能。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
| `动态图和静态图的差异 <https://www.paddlepaddle.org.cn/tutorials/projectdetail/2134396#anchor-8>`_。 | ||
|
|
||
|
|
||
| 以下将详细地介绍动静转换的各个模块内容: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| 以下将详细地介绍动静转换的各个模块内容: | |
| **以下将详细地介绍动静转换的各个模块内容:** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ok
| .. centered:: 图1 飞桨框架动静统一方案示意图 | ||
|
|
||
| .. note:: | ||
| 飞桨框架 2.0 及以上版本默认的编程模式是动态图模式,包括使用高层 API 编程和基础的 API 编程。如果想切换到静态图模式编程,可以在程序的开始执行 `enable_static()` 函数。如果程序已经使用动态图的模式编写了,想转成静态图模式训练或者保存模型用于部署,可以使用装饰器 @to_static。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
添加note时,下面第一行不用空格,顶头写就好,否则看起来展示效果会有问题
| 飞桨框架 2.0 及以上版本默认的编程模式是动态图模式,包括使用高层 API 编程和基础的 API 编程。如果想切换到静态图模式编程,可以在程序的开始执行 `enable_static()` 函数。如果程序已经使用动态图的模式编写了,想转成静态图模式训练或者保存模型用于部署,可以使用装饰器 @to_static。 | |
| 飞桨框架 2.0 及以上版本默认的编程模式是动态图模式,包括使用高层 API 编程和基础的 API 编程。如果想切换到静态图模式编程,可以在程序的开始执行 `enable_static()` 函数。如果程序已经使用动态图的模式编写了,想转成静态图模式训练或者保存模型用于部署,可以使用装饰器 @to_static。 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
不加空格,注解的格式出不来。
| :width: 500px | ||
| :align: center | ||
|
|
||
| .. centered:: 图1 飞桨框架动静统一方案示意图 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
这个居中语法似乎没有生效
TCChenlong
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
* Move @to_static pnd into parent dir (#4045) * Refactor @to_static tutorial doc (#4044) * Refactor @to_static turial doc * polish code * refine content * refine doc * fix web link * polish doc * fix code style * Refine dy2stat docs (#4103) * refine dy2stat docs * fix index_cn.rst * fix code review * modify the explanation for imgs * change title * 动转静概述更新 (#4099) * 动转静概述更新 更新动转静概述章节,补充两个Block,什么是动态图和静态图,什么场景下需要动态图转成静态图 * 动转静概述更新 增加动转静方案示意图 * update style update style * update style * Update index_cn.rst * 修复格式问题 * update codes Co-authored-by: Chen Long <[email protected]> * fix jit (#4128) * fix jit * fix jit * add jit example * fix style * fix style * update to 2.2.1 (#4133) Co-authored-by: Aurelius84 <[email protected]> Co-authored-by: 0x45f <[email protected]> Co-authored-by: moguguo <[email protected]> Co-authored-by: Chen Long <[email protected]>
更新动转静概述章节,补充两个Block,什么是动态图和静态图,什么场景下需要动态图转成静态图