未验证 提交 3b069203 编写于 作者: J Jiabin Yang 提交者: GitHub

Cherry pick en doc (#20471)

* test=document_fix, test=release/1.6, refine en doc (#20317)

* test=develop, fix docker with paddle nccl problem

* test=develop, refine en_doc for Variable and Program

* test=document_fix, fix English doc for Variable and Program

* test=document_fix, refine astype code block style

* test=document_fix, add example code for Variable properties

* test=release/1.6, test=document_fix, Refine en doc (#20409)

* test=develop, fix docker with paddle nccl problem

* test=develop, refine en_doc for Variable and Program

* test=document_fix, fix English doc for Variable and Program

* test=document_fix, refine astype code block style

* test=document_fix, add example code for Variable properties

* test=document_fix, fix BackwardStrategy English Doc

* test=document_fix, fix syntax

* test=document_fix, refresh API.spec

* test=document_fix, refine api spec

* test=document_fix, refine api spec

* test=release/1.6, test=document_fix, remove useless files
上级 95ed04f6
...@@ -898,7 +898,7 @@ paddle.fluid.dygraph.CosineDecay ('paddle.fluid.dygraph.learning_rate_scheduler. ...@@ -898,7 +898,7 @@ paddle.fluid.dygraph.CosineDecay ('paddle.fluid.dygraph.learning_rate_scheduler.
paddle.fluid.dygraph.CosineDecay.__init__ (ArgSpec(args=['self', 'learning_rate', 'step_each_epoch', 'epochs', 'begin', 'step', 'dtype'], varargs=None, keywords=None, defaults=(0, 1, 'float32')), ('document', '6adf97f83acf6453d4a6a4b1070f3754')) paddle.fluid.dygraph.CosineDecay.__init__ (ArgSpec(args=['self', 'learning_rate', 'step_each_epoch', 'epochs', 'begin', 'step', 'dtype'], varargs=None, keywords=None, defaults=(0, 1, 'float32')), ('document', '6adf97f83acf6453d4a6a4b1070f3754'))
paddle.fluid.dygraph.CosineDecay.create_lr_var (ArgSpec(args=['self', 'lr'], varargs=None, keywords=None, defaults=None), ('document', '013bc233558149d0757b3df57845b866')) paddle.fluid.dygraph.CosineDecay.create_lr_var (ArgSpec(args=['self', 'lr'], varargs=None, keywords=None, defaults=None), ('document', '013bc233558149d0757b3df57845b866'))
paddle.fluid.dygraph.CosineDecay.step (ArgSpec(args=['self'], varargs=None, keywords=None, defaults=None), ('document', '6adf97f83acf6453d4a6a4b1070f3754')) paddle.fluid.dygraph.CosineDecay.step (ArgSpec(args=['self'], varargs=None, keywords=None, defaults=None), ('document', '6adf97f83acf6453d4a6a4b1070f3754'))
paddle.fluid.dygraph.BackwardStrategy ('paddle.fluid.core_avx.BackwardStrategy', ('document', '5d9496052ec793810c9f12ffad5c73ce')) paddle.fluid.dygraph.BackwardStrategy ('paddle.fluid.core_avx.BackwardStrategy', ('document', '4fcdc2c2d0c162f3840737abda39eb27'))
paddle.fluid.dygraph.BackwardStrategy.__init__ __init__(self: paddle.fluid.core_avx.BackwardStrategy) -> None paddle.fluid.dygraph.BackwardStrategy.__init__ __init__(self: paddle.fluid.core_avx.BackwardStrategy) -> None
paddle.fluid.transpiler.DistributeTranspiler ('paddle.fluid.transpiler.distribute_transpiler.DistributeTranspiler', ('document', 'b2b19821c5dffcd11473d6a4eef089af')) paddle.fluid.transpiler.DistributeTranspiler ('paddle.fluid.transpiler.distribute_transpiler.DistributeTranspiler', ('document', 'b2b19821c5dffcd11473d6a4eef089af'))
paddle.fluid.transpiler.DistributeTranspiler.__init__ (ArgSpec(args=['self', 'config'], varargs=None, keywords=None, defaults=(None,)), ('document', '6adf97f83acf6453d4a6a4b1070f3754')) paddle.fluid.transpiler.DistributeTranspiler.__init__ (ArgSpec(args=['self', 'config'], varargs=None, keywords=None, defaults=(None,)), ('document', '6adf97f83acf6453d4a6a4b1070f3754'))
......
...@@ -180,28 +180,36 @@ void BindImperative(py::module *m_ptr) { ...@@ -180,28 +180,36 @@ void BindImperative(py::module *m_ptr) {
py::class_<imperative::detail::BackwardStrategy> backward_strategy( py::class_<imperative::detail::BackwardStrategy> backward_strategy(
m, "BackwardStrategy", R"DOC( m, "BackwardStrategy", R"DOC(
BackwardStrategy is a descriptor of a how to run the backward process. Now it has: BackwardStrategy is a descriptor of how to run the backward process.
1. :code:`sort_sum_gradient`, which will sum the gradient by the reverse order of trace. **Note**:
**This API is only avaliable in** `Dygraph <../../user_guides/howto/dygraph/DyGraph.html>`_ **Mode**
Examples: Attribute:
**sort_sum_gradient**:
.. code-block:: python If framework will sum the gradient by the reverse order of trace. eg. x_var ( :ref:`api_guide_Variable` ) will be the input of multiple OP such as :ref:`api_fluid_layers_scale` , this attr will decide if framework will sum gradient of `x_var` by the reverse order.
import numpy as np By Default: False
import paddle.fluid as fluid
from paddle.fluid import FC
x = np.ones([2, 2], np.float32) Examples:
with fluid.dygraph.guard(): .. code-block:: python
inputs2 = []
for _ in range(10): import numpy as np
inputs2.append(fluid.dygraph.base.to_variable(x)) import paddle.fluid as fluid
ret2 = fluid.layers.sums(inputs2)
loss2 = fluid.layers.reduce_sum(ret2) x = np.ones([2, 2], np.float32)
backward_strategy = fluid.dygraph.BackwardStrategy() with fluid.dygraph.guard():
backward_strategy.sort_sum_gradient = True x_var = fluid.dygraph.to_variable(x)
loss2.backward(backward_strategy) sums_inputs = []
# x_var will be multi-scales' input here
for _ in range(10):
sums_inputs.append(fluid.layers.scale(x_var))
ret2 = fluid.layers.sums(sums_inputs)
loss2 = fluid.layers.reduce_sum(ret2)
backward_strategy = fluid.dygraph.BackwardStrategy()
backward_strategy.sort_sum_gradient = True
loss2.backward(backward_strategy)
)DOC"); )DOC");
backward_strategy.def(py::init()) backward_strategy.def(py::init())
.def_property("sort_sum_gradient", .def_property("sort_sum_gradient",
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册