From a00cddd24417be639ff42da7893ffb47b27c1171 Mon Sep 17 00:00:00 2001 From: Chen Weihang Date: Thu, 9 Apr 2020 17:35:34 +0800 Subject: [PATCH] Fix several cn doc sample code diff (#1967) * fix build strategy cn doc sample code diff * fix code error * fix execution strategy error * fix LayerNorm error --- doc/fluid/api_cn/dygraph_cn/LayerNorm_cn.rst | 4 ++-- doc/fluid/api_cn/fluid_cn/BuildStrategy_cn.rst | 4 +++- doc/fluid/api_cn/fluid_cn/ExecutionStrategy_cn.rst | 2 +- 3 files changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/fluid/api_cn/dygraph_cn/LayerNorm_cn.rst b/doc/fluid/api_cn/dygraph_cn/LayerNorm_cn.rst index 96ef96491..7078bf066 100644 --- a/doc/fluid/api_cn/dygraph_cn/LayerNorm_cn.rst +++ b/doc/fluid/api_cn/dygraph_cn/LayerNorm_cn.rst @@ -47,7 +47,7 @@ LayerNorm x = numpy.random.random((3, 32, 32)).astype('float32') with fluid.dygraph.guard(): x = to_variable(x) - layernorm = fluid.LayerNorm('LayerNorm', begin_norm_axis=1) - ret = layernorm(x) + layerNorm = fluid.LayerNorm([32, 32]) + ret = layerNorm(x) diff --git a/doc/fluid/api_cn/fluid_cn/BuildStrategy_cn.rst b/doc/fluid/api_cn/fluid_cn/BuildStrategy_cn.rst index 98cb0e800..bb8ae4d2a 100644 --- a/doc/fluid/api_cn/fluid_cn/BuildStrategy_cn.rst +++ b/doc/fluid/api_cn/fluid_cn/BuildStrategy_cn.rst @@ -7,7 +7,7 @@ BuildStrategy .. py:class:: paddle.fluid.BuildStrategy -``BuildStrategy`` 使用户更方便地控制[ ``ParallelExecutor`` ](../fluid_cn.html\#parallelexecutor)中计算图的建造方法,可通过设置 ``ParallelExecutor`` 中的 ``BuildStrategy`` 成员来实现此功能。 +``BuildStrategy`` 使用户更方便地控制 :ref:`cn_api_fluid_ParallelExecutor` 中计算图的建造方法,可通过设置 ``ParallelExecutor`` 中的 ``BuildStrategy`` 成员来实现此功能。 **代码示例** @@ -68,6 +68,7 @@ bool类型。表明是否融合(fuse) broadcast ops。该选项指在Reduce模 **代码示例** .. code-block:: python + import paddle.fluid as fluid build_strategy = fluid.BuildStrategy() build_strategy.fuse_broadcast_ops = True @@ -108,6 +109,7 @@ bool类型。表明是否融合(fuse) relu和depthwise_conv2d,节省GPU内存 import os import numpy as np + import paddle.fluid as fluid import paddle.fluid.compiler as compiler use_cuda = True diff --git a/doc/fluid/api_cn/fluid_cn/ExecutionStrategy_cn.rst b/doc/fluid/api_cn/fluid_cn/ExecutionStrategy_cn.rst index 4d6cc28fa..4e26c1e23 100644 --- a/doc/fluid/api_cn/fluid_cn/ExecutionStrategy_cn.rst +++ b/doc/fluid/api_cn/fluid_cn/ExecutionStrategy_cn.rst @@ -33,7 +33,7 @@ ExecutionStrategy train_exe = fluid.ParallelExecutor(use_cuda=False, loss_name=avg_loss.name, - exec_strategy=exec_strategy) + exec_strategy=exec_strategy) .. py:attribute:: num_iteration_per_drop_scope -- GitLab