diff --git a/doc/fluid/api/gen_doc.py b/doc/fluid/api/gen_doc.py index 3c910360a3daa205dcaca3a7c4ab0190c4c57d85..2b9979a9f1a628a7a72951ee4cb81003f62b8d62 100644 --- a/doc/fluid/api/gen_doc.py +++ b/doc/fluid/api/gen_doc.py @@ -86,7 +86,6 @@ class DocGenerator(object): :noindex: '''.format(self.module_name, name)) - self._print_cn_ref(name) def print_method(self, name): self._print_ref_(name) @@ -95,7 +94,6 @@ class DocGenerator(object): :noindex: '''.format(self.module_name, name)) - self._print_cn_ref(name) def _print_header_(self, name, dot, is_title): dot_line = dot * len(name) @@ -111,9 +109,6 @@ class DocGenerator(object): def _print_ref_(self, name): self.stream.write(".. _api_{0}_{1}:\n\n".format("_".join( self.module_name.split(".")), name)) - def _print_cn_ref(self, name): - self.stream.write("Read Chinese Version: :ref:`cn_api_{0}_{1}`\n\n".format("_".join( - self.module_name.split(".")),name)) def main(): diff --git a/doc/fluid/api_cn/average_cn.rst b/doc/fluid/api_cn/average_cn.rst index cf55798fb6d562287186688ef4e45aeb999ccbe9..b3db39ba52eeb8ee7e4f23aaa5981dbdddeaaafd 100644 --- a/doc/fluid/api_cn/average_cn.rst +++ b/doc/fluid/api_cn/average_cn.rst @@ -1,4 +1,3 @@ - ################# fluid.average ################# @@ -8,7 +7,7 @@ .. _cn_api_fluid_average_WeightedAverage: WeightedAverage ->>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.average.WeightedAverage @@ -65,5 +64,7 @@ WeightedAverage -英文版API文档: :ref:`api_fluid_average_WeightedAverage` + + + diff --git a/doc/fluid/api_cn/backward_cn.rst b/doc/fluid/api_cn/backward_cn.rst index ad8cdd3c00ca9531eb6f6428b88afd6d03a10927..9e23d7b86f6dad4b7292750e7bc96819e9447ea0 100644 --- a/doc/fluid/api_cn/backward_cn.rst +++ b/doc/fluid/api_cn/backward_cn.rst @@ -1,4 +1,3 @@ - ################# fluid.backward ################# @@ -8,7 +7,7 @@ .. _cn_api_fluid_backward_append_backward: append_backward ->>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.backward.append_backward(loss, parameter_list=None, no_grad_set=None, callbacks=None) @@ -86,5 +85,7 @@ append_backward -英文版API文档: :ref:`api_fluid_backward_append_backward` + + + diff --git a/doc/fluid/api_cn/clip_cn.rst b/doc/fluid/api_cn/clip_cn.rst index 83e08a9948e5e07d2804189f4e94e4f582e833da..4de9347b8da7604d1300970420b54603bb8805d6 100644 --- a/doc/fluid/api_cn/clip_cn.rst +++ b/doc/fluid/api_cn/clip_cn.rst @@ -1,4 +1,3 @@ - ################# fluid.clip ################# @@ -8,7 +7,7 @@ .. _cn_api_fluid_clip_ErrorClipByValue: ErrorClipByValue ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.clip.ErrorClipByValue(max, min=None) @@ -34,12 +33,14 @@ ErrorClipByValue -英文版API文档: :ref:`api_fluid_clip_ErrorClipByValue` + + + .. _cn_api_fluid_clip_GradientClipByGlobalNorm: GradientClipByGlobalNorm ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.clip.GradientClipByGlobalNorm(clip_norm, group_name='default_group') @@ -78,12 +79,14 @@ GradientClipByGlobalNorm -英文版API文档: :ref:`api_fluid_clip_GradientClipByGlobalNorm` + + + .. _cn_api_fluid_clip_GradientClipByNorm: GradientClipByNorm ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.clip.GradientClipByNorm(clip_norm) @@ -116,12 +119,14 @@ GradientClipByNorm -英文版API文档: :ref:`api_fluid_clip_GradientClipByNorm` + + + .. _cn_api_fluid_clip_GradientClipByValue: GradientClipByValue ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.clip.GradientClipByValue(max, min=None) @@ -152,5 +157,7 @@ GradientClipByValue -英文版API文档: :ref:`api_fluid_clip_GradientClipByValue` + + + diff --git a/doc/fluid/api_cn/data_feeder_cn.rst b/doc/fluid/api_cn/data_feeder_cn.rst index 111242d54158fa6ef7beccac0d06d5e25f04108e..d157397c16cb5f23be32a172d8e31de1f53d4bfb 100644 --- a/doc/fluid/api_cn/data_feeder_cn.rst +++ b/doc/fluid/api_cn/data_feeder_cn.rst @@ -1,14 +1,13 @@ - -################# -fluid.data_feeder -################# +################### + fluid.data_feeder +################### .. _cn_api_fluid_data_feeder_DataFeeder: DataFeeder ->>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.data_feeder.DataFeeder(feed_list, place, program=None) @@ -101,10 +100,10 @@ reader通常返回一个minibatch条目列表。在列表中每一条目都是 将reader返回的输入数据batch转换为多个mini-batch,之后每个mini-batch都会被输入进各个设备(CPU或GPU)中。 参数: - - **reader** (fun) – 待输入的数据 - - **multi_devices** (bool) – 执行场所的数目,默认为None - - **num_places** (int) – 执行场所的数目,默认为None - - **drop_last** (bool) – 舍弃数目匹配不上的batch或设备 + - **reader** (fun) – 该参数是一个可以生成数据的函数 + - **multi_devices** (bool) – bool型,指明是否使用多个设备 + - **num_places** (int) – 如果 ``multi_devices`` 为 ``True`` , 可以使用此参数来设置GPU数目。如果 ``num_places`` 为 ``None`` ,该函数默认使用当前训练机所有GPU设备。默认为None。 + - **drop_last** (bool) – 如果最后一个batch的大小比 ``batch_size`` 要小,则可使用该参数来指明是否选择丢弃最后一个batch数据。 默认为 ``True`` 返回:转换结果 @@ -117,5 +116,7 @@ reader通常返回一个minibatch条目列表。在列表中每一条目都是 -英文版API文档: :ref:`api_fluid_data_feeder_DataFeeder` + + + diff --git a/doc/fluid/api_cn/executor_cn.rst b/doc/fluid/api_cn/executor_cn.rst index feeb1f28311b2beaba983f2b1d5a9e1039d91876..595fc0aed2077e0a982045799515ed6af8e50a08 100644 --- a/doc/fluid/api_cn/executor_cn.rst +++ b/doc/fluid/api_cn/executor_cn.rst @@ -1,14 +1,13 @@ - ################# fluid.executor ################# -.. _cn_api_fluid_executor: +.. _cn_api_fluid_executor_Executor: Executor ->>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.executor.Executor (place) @@ -107,5 +106,64 @@ feed map为该program提供输入数据。fetch_list提供program训练结束后 -英文版API文档: :ref:`api_fluid_executor` + + + + + + +.. _cn_api_fluid_executor_global_scope: + +global_scope +------------------------------- + +.. py:function:: paddle.fluid.global_scope() + + +获取全局/默认作用域实例。很多api使用默认 ``global_scope`` ,例如 ``Executor.run`` 。 + +返回:全局/默认作用域实例 + +返回类型:Scope + + + + + + +.. _cn_api_fluid_executor_scope_guard: + +scope_guard +------------------------------- + +.. py:function:: paddle.fluid.scope_guard(*args, **kwds) + + +修改全局/默认作用域(scope), 运行时中的所有变量都将分配给新的scope。 + +参数: + - **scope** - 新的全局/默认 scope。 + +**代码示例** + +.. code-block:: python + + import paddle.fluid as fluid + + new_scope = fluid.Scope() + with fluid.scope_guard(new_scope): + ... + + + + + + + + + + + + + diff --git a/doc/fluid/api_cn/fluid_cn.rst b/doc/fluid/api_cn/fluid_cn.rst index 3ba5d33af4e15e7e53cbba1564f44ab57065e3d0..813216b0deeda5bb6d18044cd19ae0089362c0e3 100644 --- a/doc/fluid/api_cn/fluid_cn.rst +++ b/doc/fluid/api_cn/fluid_cn.rst @@ -1,6 +1,5 @@ - ################# -fluid + fluid ################# @@ -8,7 +7,7 @@ fluid .. _cn_api_fluid_AsyncExecutor: AsyncExecutor ->>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.AsyncExecutor(place=None) @@ -48,14 +47,39 @@ AsyncExecutor正在积极开发,API可能在不久的将来会发生变化。 目前仅支持CPU +.. py:method:: run(program, data_feed, filelist, thread_num, fetch, debug=False) + +使用此 ``AsyncExecutor`` 来运行 ``program`` 。 + +``filelist`` 中包含训练数据集。用户也可以通过在参数 ``fetch`` 中提出变量来检查特定的变量, 正如 ``fluid.Executor`` 。 + +但不像 ``fluid.Executor`` , ``AsyncExecutor`` 不返回获取到的变量,而是将每个获取到的变量作为标准输出展示给用户。 + +数据集上的运算在多个线程上执行,每个线程中都会独立出一个线程本地作用域,并在此域中建立运算。 +所有运算同时更新参数值。 + +参数: + - program (Program) – 需要执行的program。如果没有提供该参数,默认使用 ``default_main_program`` + - data_feed (DataFeedDesc) – ``DataFeedDesc`` 对象 + - filelist (str) – 一个包含训练数据集文件的文件列表 + - thread_num (int) – 并发训练线程数。参照 *注解* 部分获取合适的设置方法 + - fetch (str|list) – 变量名,或者变量名列表。指明最后要进行观察的变量命名 + - debug (bool) – 如果为True, 在每一个minibatch处理后,fetch 中指明的变量将会通过标准输出打印出来 + +.. note:: + 1.该执行器会运行program中的所有运算,不只是那些依赖于fetchlist的运算 + + 2.该类执行器在多线程上运行,每个线程占用一个CPU核。为了实现效率最大化,建议将 ``thread_num`` 等于或稍微小于CPU核心数 + + + -英文版API文档: :ref:`api_fluid_AsyncExecutor` .. _cn_api_fluid_BuildStrategy: BuildStrategy ->>>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.BuildStrategy @@ -105,38 +129,48 @@ str类型。在 ``ParallelExecutor`` 中,存在两种减少策略(reduce str -英文版API文档: :ref:`api_fluid_BuildStrategy` + + + .. _cn_api_fluid_CPUPlace: CPUPlace ->>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.CPUPlace -英文版API文档: :ref:`api_fluid_CPUPlace` + + + .. _cn_api_fluid_create_lod_tensor: create_lod_tensor ->>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.create_lod_tensor(data, recursive_seq_lens, place) 该函数从一个numpy数组,列表或者已经存在的lod tensor中创建一个lod tensor。 + 通过一下几步实现: - 1. 检查length-based level of detail (LoD,长度为基准的细节层次),或称recursive_sequence_lengths(递归序列长度)的正确性 - 2. 将recursive_sequence_lengths转化为offset-based LoD(偏移量为基准的LoD) - 3. 把提供的numpy数组,列表或者已经存在的lod tensor复制到CPU或GPU中(依据执行场所确定) - 4. 利用offset-based LoD来设置LoD + +1. 检查length-based level of detail (LoD,长度为基准的细节层次),或称recursive_sequence_lengths(递归序列长度)的正确性 + +2. 将recursive_sequence_lengths转化为offset-based LoD(偏移量为基准的LoD) + +3. 把提供的numpy数组,列表或者已经存在的lod tensor复制到CPU或GPU中(依据执行场所确定) + +4. 利用offset-based LoD来设置LoD + 例如: 假如我们想用LoD Tensor来承载一词序列的数据,其中每个词由一个整数来表示。现在,我们意图创建一个LoD Tensor来代表两个句子,其中一个句子有两个词,另外一个句子有三个。 - 那么数据可以是一个numpy数组,形状为(5,1)。同时, ``recursive_seq_lens`` 为 [[2, 3]],表明各个句子的长度。这个长度为基准的 ``recursive_seq_lens`` 将在函数中会被转化为以偏移量为基准的 LoD [[0, 2, 5]]。 + 那么数 ``data`` 可以是一个numpy数组,形状为(5,1)。同时, ``recursive_seq_lens`` 为 [[2, 3]],表明各个句子的长度。这个长度为基准的 ``recursive_seq_lens`` 将在函数中会被转化为以偏移量为基准的 LoD [[0, 2, 5]]。 参数: - **data** (numpy.ndarray|list|LoDTensor) – 容纳着待复制数据的一个numpy数组、列表或LoD Tensor @@ -151,13 +185,15 @@ create_lod_tensor -英文版API文档: :ref:`api_fluid_create_lod_tensor` + + + .. _cn_api_fluid_create_random_int_lodtensor: create_random_int_lodtensor ->>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.create_random_int_lodtensor(recursive_seq_lens, base_shape, place, low, high) @@ -169,9 +205,9 @@ create_random_int_lodtensor 该函数实现以下功能: - 1. 根据用户输入的length-based ``recursive_seq_lens`` (基于长度的递归序列长)和在 ``basic_shape`` 中的基本元素形状计算LoDTensor的整体形状 - 2. 由此形状,建立numpy数组 - 3. 使用API: ``create_lod_tensor`` 建立LoDTensor +1. 根据用户输入的length-based ``recursive_seq_lens`` (基于长度的递归序列长)和在 ``basic_shape`` 中的基本元素形状计算LoDTensor的整体形状 +2. 由此形状,建立numpy数组 +3. 使用API: ``create_lod_tensor`` 建立LoDTensor 假如我们想用LoD Tensor来承载一词序列,其中每个词由一个整数来表示。现在,我们意图创建一个LoD Tensor来代表两个句子,其中一个句子有两个词,另外一个句子有三个。那么 ``base_shape`` 为[1], 输入的length-based ``recursive_seq_lens`` 是 [[2, 3]]。那么LoDTensor的整体形状应为[5, 1],并且为两个句子存储5个词。 @@ -193,12 +229,14 @@ create_random_int_lodtensor -英文版API文档: :ref:`api_fluid_create_random_int_lodtensor` + + + .. _cn_api_fluid_CUDAPinnedPlace: CUDAPinnedPlace ->>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.CUDAPinnedPlace @@ -209,24 +247,28 @@ CUDAPinnedPlace -英文版API文档: :ref:`api_fluid_CUDAPinnedPlace` + + + .. _cn_api_fluid_CUDAPlace: CUDAPlace ->>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.CUDAPlace -英文版API文档: :ref:`api_fluid_CUDAPlace` + + + .. _cn_api_fluid_DataFeedDesc: DataFeedDesc ->>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.DataFeedDesc(proto_file) @@ -267,7 +309,7 @@ DataFeedDesc应由来自磁盘的有效protobuf消息初始化: DataFeedDesc也可以在运行时更改。一旦你熟悉了每个字段的含义,您可以修改它以更好地满足您的需要。例如: -.. code-block:: text +.. code-block:: python data_feed.set_batch_size(128) data_feed.set_dense_slots('wd') # The slot named 'wd' will be dense @@ -277,6 +319,7 @@ DataFeedDesc也可以在运行时更改。一旦你熟悉了每个字段的含 print(data_feed.desc()) + 参数: - **proto_file** (string) - 包含数据feed中描述的磁盘文件 @@ -351,12 +394,14 @@ DataFeedDesc也可以在运行时更改。一旦你熟悉了每个字段的含 print(data_feed.desc()) -英文版API文档: :ref:`api_fluid_DataFeedDesc` + + + .. _cn_api_fluid_DataFeeder: DataFeeder ->>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.DataFeeder(feed_list, place, program=None) @@ -387,13 +432,14 @@ reader通常返回一个minibatch条目列表。在列表中每一条目都是 -参数: - - **feed_list** (list) – 向模型输入的变量表或者变量表名 - - **place** (Place) – place表明是向GPU还是CPU中输入数据。如果想向GPU中输入数据, 请使用 ``fluid.CUDAPlace(i)`` (i 代表 the GPU id);如果向CPU中输入数据, 请使用 ``fluid.CPUPlace()`` - - **program** (Program) – 需要向其中输入数据的Program。如果为None, 会默认使用 ``default_main_program()``。 缺省值为None +参数: + - **feed_list** (list) – 向模型输入的变量表或者变量表名 + - **place** (Place) – place表明是向GPU还是CPU中输入数据。如果想向GPU中输入数据, 请使用 ``fluid.CUDAPlace(i)`` (i 代表 the GPU id);如果向CPU中输入数据, 请使用 ``fluid.CPUPlace()`` + - **program** (Program) – 需要向其中输入数据的Program。如果为None, 会默认使用 ``default_main_program()``。 缺省值为None -弹出异常: ``ValueError`` – 如果一些变量不在此 Program 中 +抛出异常: + - ``ValueError`` – 如果一些变量不在此 Program 中 **代码示例** @@ -437,7 +483,8 @@ reader通常返回一个minibatch条目列表。在列表中每一条目都是 返回类型: dict -**特别注意:** 设备(CPU或GPU)的数目必须等于minibatch的数目 +.. note:: + 设备(CPU或GPU)的数目必须等于minibatch的数目 @@ -448,16 +495,16 @@ reader通常返回一个minibatch条目列表。在列表中每一条目都是 将reader返回的输入数据batch转换为多个mini-batch,之后每个mini-batch都会被输入进各个设备(CPU或GPU)中。 参数: - - **reader** (fun) – 待输入的数据 - - **multi_devices** (bool) – 执行场所的数目,默认为None - - **num_places** (int) – 执行场所的数目,默认为None - - **drop_last** (bool) – 舍弃数目匹配不上的batch或设备 + - **reader** (fun) – 该参数是一个可以生成数据的函数 + - **multi_devices** (bool) – bool型,指明是否使用多个设备 + - **num_places** (int) – 如果 ``multi_devices`` 为 ``True`` , 可以使用此参数来设置GPU数目。如果 ``num_places`` 为 ``None`` ,该函数默认使用当前训练机所有GPU设备。默认为None。 + - **drop_last** (bool) – 如果最后一个batch的大小比 ``batch_size`` 要小,则可使用该参数来指明是否选择丢弃最后一个batch数据。 默认为 ``True`` 返回:转换结果 返回类型: dict -弹出异常: ``ValueError`` – 如果 ``drop_last`` 值为False并且reader返回的minibatch数目与设备数目不相等时,产生此异常 +抛出异常: ``ValueError`` – 如果 ``drop_last`` 值为False并且reader返回的minibatch数目与设备数目不相等时,产生此异常 @@ -466,12 +513,14 @@ reader通常返回一个minibatch条目列表。在列表中每一条目都是 -英文版API文档: :ref:`api_fluid_DataFeeder` + + + .. _cn_api_fluid_default_main_program: default_main_program ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.default_main_program() @@ -497,7 +546,9 @@ default_main_program -英文版API文档: :ref:`api_fluid_default_main_program` + + + .. _cn_api_fluid_default_startup_program: @@ -505,7 +556,7 @@ default_main_program default_startup_program ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.default_startup_program() @@ -529,12 +580,14 @@ startup_program会使用内在的operators(算子)去初始化他们,并 -英文版API文档: :ref:`api_fluid_default_startup_program` + + + .. _cn_api_fluid_DistributeTranspiler: DistributeTranspiler ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.DistributeTranspiler (config=None) @@ -590,6 +643,7 @@ DistributeTranspiler 参数: - **trainer_id** (int) – 当前Trainer worker的id, 如果有n个Trainer worker, id 取值范围为0 ~ n-1 - **program** (Program|None) – 待transpile(转译)的program, 缺省为 ``fluid.default_main_program()`` + - **startup_program** (Program|None) - 要转译的 ``startup_program`` ,默认为 ``fluid.default_startup_program()`` - **pservers** (str) – 内容为Pserver列表的字符串,格式为:按逗号区分不同的Pserver,每个Pserver的格式为 *ip地址:端口号* - **trainers** (int|str) – 在Pserver模式下,该参数指Trainer机的个数;在nccl2模式下,它是一个内容为Trainer终端列表的字符串 - **sync_mode** (bool) – 是否做同步训练(synchronous training), 默认为True @@ -652,12 +706,14 @@ DistributeTranspiler -英文版API文档: :ref:`api_fluid_DistributeTranspiler` + + + .. _cn_api_fluid_DistributeTranspilerConfig: DistributeTranspilerConfig ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.DistributeTranspilerConfig @@ -680,12 +736,14 @@ DistributeTranspilerConfig -英文版API文档: :ref:`api_fluid_DistributeTranspilerConfig` + + + .. _cn_api_fluid_ExecutionStrategy: ExecutionStrategy ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.ExecutionStrategy @@ -734,12 +792,14 @@ int型成员。它代表了线程池(thread pool)的大小。这些线程会被 -英文版API文档: :ref:`api_fluid_ExecutionStrategy` + + + .. _cn_api_fluid_executor: Executor ->>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.Executor (place) @@ -843,26 +903,14 @@ feed map为该program提供输入数据。fetch_list提供program训练结束后 -英文版API文档: :ref:`api_fluid_executor` - -.. _cn_api_fluid_fluid_Tensor: - -Tensor ->>>>>>>>>>>>>>>>>>>>>>>>> - -.. py:function:: paddle.fluid.Tensor - - ``LoDTensor`` 的别名 - -英文版API文档: :ref:`api_fluid_fluid_Tensor` .. _cn_api_fluid_global_scope: global_scope ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.global_scope() @@ -875,19 +923,24 @@ global_scope -英文版API文档: :ref:`api_fluid_global_scope` + + + .. _cn_api_fluid_LoDTensor: LoDTensor ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.LoDTensor LoDTensor是一个具有LoD信息的张量(Tensor) - ``np.array(lod_tensor)`` 可以将LoDTensor转换为numpy array。 ``lod_tensor.lod()`` 可以获得LoD信息。 +``np.array(lod_tensor)`` 可以将LoDTensor转换为numpy array。 + +``lod_tensor.lod()`` 可以获得LoD信息。 + LoD是多层序列(Level of Details)的缩写,通常用于不同长度的序列。如果您不需要了解LoD信息,可以跳过下面的注解。 举例: @@ -939,12 +992,14 @@ LoD可以有多个level(例如,一个段落可以有多个句子,一个句 -英文版API文档: :ref:`api_fluid_LoDTensor` + + + .. _cn_api_fluid_LoDTensorArray: LoDTensorArray ->>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.LoDTensorArray @@ -954,19 +1009,22 @@ LoDTensorArray -英文版API文档: :ref:`api_fluid_LoDTensorArray` + + + .. _cn_api_fluid_memory_optimize: memory_optimize ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.memory_optimize(input_program, skip_opt_set=None, print_log=False, level=0, skip_grads=False) 通过重用var内存来优化内存。 -注意:它不支持block中嵌套子block。 +.. note:: + 它不支持block中嵌套子block。 参数: - **input_program** (str) – 输入Program。 @@ -979,12 +1037,14 @@ memory_optimize -英文版API文档: :ref:`api_fluid_memory_optimize` + + + .. _cn_api_fluid_name_scope: name_scope ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.name_scope(*args, **kwds) @@ -1009,12 +1069,14 @@ name_scope -英文版API文档: :ref:`api_fluid_name_scope` + + + .. _cn_api_fluid_ParallelExecutor: ParallelExecutor ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.ParallelExecutor(use_cuda, loss_name=None, main_program=None, share_vars_from=None, exec_strategy=None, build_strategy=None, num_trainers=1, trainer_id=0, scope=None) @@ -1041,7 +1103,7 @@ ParallelExecutor 返回类型: ParallelExecutor -弹出异常:``TypeError`` - 如果提供的参数 ``share_vars_from`` 不是 ``ParallelExecutor`` 类型的,将会弹出此异常 +抛出异常:``TypeError`` - 如果提供的参数 ``share_vars_from`` 不是 ``ParallelExecutor`` 类型的,将会弹出此异常 **代码示例** @@ -1096,14 +1158,12 @@ ParallelExecutor 返回类型:List -弹出异常: - ``ValueError`` - 如果feed参数是list类型,但是它的长度不等于可用设备(执行场所)的数目,再或者给定的feed不是dict类型,弹出此异常 - - ``TypeError`` - 如果feed参数是list类型,但是它里面的元素不是dict类型时,弹出此异常 +抛出异常: + - ``ValueError`` - 如果feed参数是list类型,但是它的长度不等于可用设备(执行场所)的数目,再或者给定的feed不是dict类型,抛出此异常 + - ``TypeError`` - 如果feed参数是list类型,但是它里面的元素不是dict类型时,弹出此异常 -额外注意: - 1.如果feed参数为dict类型,那么传入 ``ParallelExecutor`` 的数据量 *必须* 大于可用的执行场所数目。否则,C++端将会弹出异常。应额外注意核对数据集的最后一个batch是否比可用执行场所数目大。 - +.. note:: + 1.如果feed参数为dict类型,那么传入 ``ParallelExecutor`` 的数据量 *必须* 大于可用的执行场所数目。否则,C++端将会抛出异常。应额外注意核对数据集的最后一个batch是否比可用执行场所数目大。 2.如果可用执行场所大于一个,则为每个变量最后获取的结果都是list类型,且这个list中的每个元素都是各个可用执行场所的变量 **代码示例** @@ -1120,13 +1180,15 @@ ParallelExecutor -英文版API文档: :ref:`api_fluid_ParallelExecutor` + + + .. _cn_api_fluid_ParamAttr: ParamAttr ->>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.ParamAttr(name=None, initializer=None, learning_rate=1.0, regularizer=None, trainable=True, gradient_clip=None, do_model_average=False) @@ -1160,12 +1222,14 @@ ParamAttr -英文版API文档: :ref:`api_fluid_ParamAttr` + + + .. _cn_api_fluid_Program: Program ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.Program @@ -1372,12 +1436,14 @@ operator的角色,值只能是枚举变量{Forward, Backward, Optimize}。 -英文版API文档: :ref:`api_fluid_Program` + + + .. _cn_api_fluid_program_guard: program_guard ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.program_guard(*args, **kwds) @@ -1420,12 +1486,14 @@ program_guard -英文版API文档: :ref:`api_fluid_program_guard` + + + .. _cn_api_fluid_release_memory: release_memory ->>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.release_memory(input_program, skip_opt_set=None) @@ -1450,14 +1518,36 @@ release_memory -英文版API文档: :ref:`api_fluid_release_memory` + + + .. _cn_api_fluid_Scope: Scope ->>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- + +.. py:class:: paddle.fluid.scope(scope) + +(作用域)Scope为变量名的联合。所有变量都属于Scope。 + +从本地作用域中可以拉取到其双亲作用域的变量。 + +要想运行一个网络,需要指明它运行所在的域,确切的说: exe.Run(&scope) 。 + +一个网络可以在不同域上运行,并且更新该域的各类变量。 + +在作用域上创建一个变量,并在域中获取。 + +**代码示例** + +.. code-block:: python + + # create tensor from a scope and set value to it. + param = scope.var('Param').get_tensor() + param_array = np.full((height, row_numel), 5.0).astype("float32") + param.set(param_array, place) -.. py:function:: paddle.fluid.scope(scope) .. py:method:: drop_kids(self: paddle.fluid.core.Scope) → None .. py:method:: find_var(self: paddle.fluid.core.Scope, arg0: unicode) → paddle.fluid.core.Variable @@ -1467,14 +1557,16 @@ Scope -英文版API文档: :ref:`api_fluid_Scope` + + + .. _cn_api_fluid_scope_guard: scope_guard ->>>>>>>>>>>> +------------------------------- -.. py:function:: paddle.fluid.scope_guard(*args, **kwds)() +.. py:function:: paddle.fluid.scope_guard(*args, **kwds) 修改全局/默认作用域(scope), 运行时中的所有变量都将分配给新的scope。 @@ -1495,25 +1587,31 @@ scope_guard -英文版API文档: :ref:`api_fluid_scope_guard` -.. _cn_api_fluid_switch_scope: -_switch_scope ->>>>>>>>>>>>>>>>>>>>>>>>> -.. py:function:: paddle.fluid._switch_scope(scope) + +.. _cn_api_fluid_Tensor: + +Tensor +------------------------------- + +.. py:function:: paddle.fluid.Tensor + + ``LoDTensor`` 的别名 + + + -英文版API文档: :ref:`api_fluid_switch_scope` .. _cn_api_fluid_WeightNormParamAttr: WeightNormParamAttr ->>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.WeightNormParamAttr(dim=None, name=None, initializer=None, learning_rate=1.0, regularizer=None, trainable=True, gradient_clip=None, do_model_average=False) @@ -1546,5 +1644,7 @@ WeightNormParamAttr -英文版API文档: :ref:`api_fluid_WeightNormParamAttr` + + + diff --git a/doc/fluid/api_cn/index_cn.rst b/doc/fluid/api_cn/index_cn.rst index ce264c1d6457775079093f6ad0f96f6d43ec63a2..ee9689c3f28842e17f2791e0a41c9328fa729ab4 100644 --- a/doc/fluid/api_cn/index_cn.rst +++ b/doc/fluid/api_cn/index_cn.rst @@ -22,4 +22,4 @@ API Reference param_attr_cn.rst profiler_cn.rst regularizer_cn.rst - transpliter_cn.rst + transpiler_cn.rst diff --git a/doc/fluid/api_cn/initializer_cn.rst b/doc/fluid/api_cn/initializer_cn.rst index 734198216ada87996a049f6820e90d9453c68e90..adc5d45fc9de2ab8457d1a729c826454f83aa716 100644 --- a/doc/fluid/api_cn/initializer_cn.rst +++ b/doc/fluid/api_cn/initializer_cn.rst @@ -1,7 +1,6 @@ - -################# +################### fluid.initializer -################# +################### .. _cn_api_fluid_initializer_Bilinear: @@ -9,9 +8,9 @@ Bilinear >>>>>>>>>>> -.. py:function:: paddle.fluid.initializer.Bilinear +.. py:attribute:: paddle.fluid.initializer.Bilinear - ``BilinearInitializer``的别名 +``BilinearInitializer`` 的别名 .. _cn_api_fluid_initializer_BilinearInitializer: @@ -45,16 +44,16 @@ num_filters = C和groups = C 表示这是按通道转置的卷积函数。滤波 -英文版API文档: :ref:`api_fluid_initializer_BilinearInitializer` + .. _cn_api_fluid_initializer_Constant: Constant >>>>>>>>>> -.. py:function:: paddle.fluid.initializer.Constant +.. py:attribute:: paddle.fluid.initializer.Constant - ``ConstantInitializer``的别名 +``ConstantInitializer`` 的别名 .. _cn_api_fluid_initializer_ConstantInitializer: @@ -78,7 +77,7 @@ ConstantInitializer -英文版API文档: :ref:`api_fluid_initializer_ConstantInitializer` + @@ -103,7 +102,7 @@ force_init_on_cpu create_op('force_cpu': force_init_on_cpu()) -英文版API文档: :ref:`api_fluid_initializer_force_init_on_cpu` + @@ -130,7 +129,7 @@ init_on_cpu -英文版API文档: :ref:`api_fluid_initializer_init_on_cpu` + .. _cn_api_fluid_initializer_MSRA: @@ -138,9 +137,9 @@ init_on_cpu MSRA >>>>>> -.. py:function:: paddle.fluid.initializer.MSRA +.. py:attribute:: paddle.fluid.initializer.MSRA - ``MSRAInitializer``的别名 +``MSRAInitializer`` 的别名 .. _cn_api_fluid_initializer_MSRAInitializer: @@ -184,7 +183,7 @@ MSRAInitializer -英文版API文档: :ref:`api_fluid_initializer_MSRAInitializer` + .. _cn_api_fluid_initializer_Normal: @@ -192,9 +191,9 @@ MSRAInitializer Normal >>>>>>>> -.. py:function:: paddle.fluid.initializer.Normal +.. py:attribute:: paddle.fluid.initializer.Normal - ``NormalInitializer``的别名 +``NormalInitializer`` 的别名 .. _cn_api_fluid_initializer_NormalInitializer: @@ -222,16 +221,16 @@ NormalInitializer -英文版API文档: :ref:`api_fluid_initializer_NormalInitializer` + .. _cn_api_fluid_initializer_TruncatedNormal: TruncatedNormal >>>>>>>>>>>>>>>>> -.. py:function:: paddle.fluid.initializer.TruncatedNormal +.. py:attribute:: paddle.fluid.initializer.TruncatedNormal - ``TruncatedNormalInitializer``的别名 +``TruncatedNormalInitializer`` 的别名 .. _cn_api_fluid_initializer_TruncatedNormalInitializer: @@ -260,7 +259,7 @@ Random Truncated Normal(高斯)分布初始化器 -英文版API文档: :ref:`api_fluid_initializer_TruncatedNormalInitializer` + .. _cn_api_fluid_initializer_Uniform: @@ -268,13 +267,14 @@ Random Truncated Normal(高斯)分布初始化器 Uniform >>>>>>>>> -.. _cn_api_fluid_initializer_UniformInitializer: +.. py:attribute:: paddle.fluid.initializer.Uniform -.. py:class:: paddle.fluid.initializer.Uniform +``UniformInitializer`` 的别名 - ``UniformInitializer``的别名 +.. _cn_api_fluid_initializer_UniformInitializer: + UniformInitializer >>>>>>>>>>>> @@ -297,16 +297,24 @@ UniformInitializer -英文版API文档: :ref:`api_fluid_initializer_UniformInitializer` -.. _api_fluid_initializer_Xavier: + + + + +.. _cn_api_fluid_initializer_Xavier: Xavier >>>>>>>>> -.. py:function:: paddle.fluid.initializer.Xavier +.. py:attribute:: paddle.fluid.initializer.Xavier + +``XavierInitializer`` 的别名 + + + + - ``XavierInitializer``的别名 .. _cn_api_fluid_initializer_XavierInitializer: @@ -351,5 +359,5 @@ XavierInitializer -英文版API文档: :ref:`api_fluid_initializer_XavierInitializer` + diff --git a/doc/fluid/api_cn/io_cn.rst b/doc/fluid/api_cn/io_cn.rst index f7a579d03748eb6f8f3046443e6f4bee8e69e8b8..6c1bd3dcceca9a049604ddd257763e10c420ce39 100644 --- a/doc/fluid/api_cn/io_cn.rst +++ b/doc/fluid/api_cn/io_cn.rst @@ -1,4 +1,3 @@ - ################# fluid.io ################# @@ -8,7 +7,7 @@ .. _cn_api_fluid_io_load_inference_model: load_inference_model ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.io.load_inference_model(dirname, executor, model_filename=None, params_filename=None, pserver_endpoints=None) @@ -44,12 +43,14 @@ load_inference_model -英文版API文档: :ref:`api_fluid_io_load_inference_model` + + + .. _cn_api_fluid_io_load_params: load_params ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.io.load_params(executor, dirname, main_program=None, filename=None) @@ -79,12 +80,14 @@ load_params -英文版API文档: :ref:`api_fluid_io_load_params` + + + .. _cn_api_fluid_io_load_persistables: load_persistables ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.io.load_persistables(executor, dirname, main_program=None, filename=None) @@ -112,12 +115,14 @@ load_persistables -英文版API文档: :ref:`api_fluid_io_load_persistables` + + + .. _cn_api_fluid_io_load_vars: load_vars ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.io.load_vars(executor, dirname, main_program=None, vars=None, predicate=None, filename=None) @@ -154,24 +159,28 @@ load_vars prog = fluid.default_main_program() fluid.io.load_vars(executor=exe, dirname=path, main_program=prog, - vars=None) + vars=None, predicate=name_has_fc) + #加载所有`main_program`中变量名包含 ‘fc’ 的变量 + #并且此前所有变量应该保存在不同文件中 - # The second usage: using `vars` to specify variables + #用法2:使用 `vars` 列表来指明变量 var_list = [var_a, var_b, var_c] fluid.io.load_vars(executor=exe, dirname=path, vars=var_list, filename="vars_file") - # var_a, var_b and var_c will be loaded. And they are supposed to haven - # been saved in the same file named 'var_file' in the path "./my_paddle_model". + # 加载 var_a , var_b , var_c .它们此前应被保存在同一文件中 + # 文件名为 'var_file' ,路径为 "./my_paddle_model". -英文版API文档: :ref:`api_fluid_io_load_vars` + + + .. _cn_api_fluid_io_save_inference_model: save_inference_model ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.io.save_inference_model(dirname, feeded_var_names, target_vars, executor, main_program=None, model_filename=None, params_filename=None, export_for_deployment=True) @@ -211,12 +220,14 @@ save_inference_model -英文版API文档: :ref:`api_fluid_io_save_inference_model` + + + .. _cn_api_fluid_io_save_params: save_params ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.io.save_params(executor, dirname, main_program=None, filename=None) @@ -248,12 +259,14 @@ save_params -英文版API文档: :ref:`api_fluid_io_save_params` + + + .. _cn_api_fluid_io_save_persistables: save_persistables ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.io.save_persistables(executor, dirname, main_program=None, filename=None) @@ -284,14 +297,14 @@ save_persistables -英文版API文档: :ref:`api_fluid_io_save_persistables` + .. _cn_api_fluid_io_save_vars: save_vars ->>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.io.save_vars(executor, dirname, main_program=None, vars=None, predicate=None, filename=None) @@ -328,7 +341,7 @@ save_vars prog = fluid.default_main_program() fluid.io.save_vars(executor=exe, dirname=path, main_program=prog, - vars=None) + vars=None, predicate = name_has_fc) # 将main_program中名中包含“fc”的的所有变量保存。 # 变量将分开保存。 @@ -341,5 +354,7 @@ save_vars -英文版API文档: :ref:`api_fluid_io_save_vars` + + + diff --git a/doc/fluid/api_cn/layers_cn.rst b/doc/fluid/api_cn/layers_cn.rst index 9a973ba86e43d891fe25f1762497d3ca774e7759..73fc9c1f1869000be1834309c51bc8abe7a58c5d 100644 --- a/doc/fluid/api_cn/layers_cn.rst +++ b/doc/fluid/api_cn/layers_cn.rst @@ -1,4 +1,3 @@ - ################### fluid.layers ################### @@ -12,7 +11,7 @@ fluid.layers .. _cn_api_fluid_layers_array_length: array_length ->>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.array_length(array) @@ -42,14 +41,16 @@ array_length -英文版API文档: :ref:`api_fluid_layers_array_length` + + + .. _cn_api_fluid_layers_array_read: array_read ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.array_read(array,i) @@ -83,14 +84,16 @@ array_read -英文版API文档: :ref:`api_fluid_layers_array_read` + + + .. _cn_api_fluid_layers_array_write: array_write ->>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.array_write(x, i, array=None) @@ -119,14 +122,16 @@ array_write -英文版API文档: :ref:`api_fluid_layers_array_write` + + + .. _cn_api_fluid_layers_create_array: create_array ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.create_array(dtype) @@ -151,14 +156,16 @@ create_array -英文版API文档: :ref:`api_fluid_layers_create_array` + + + .. _cn_api_fluid_layers_DynamicRNN: DynamicRNN ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.layers.DynamicRNN(name=None) @@ -299,14 +306,16 @@ memory用于缓存分段数据。memory的初始值可以是零,也可以是 -英文版API文档: :ref:`api_fluid_layers_DynamicRNN` + + + .. _cn_api_fluid_layers_equal: equal ->>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.equal(x,y,cond=None,**ignored) @@ -330,14 +339,16 @@ equal -英文版API文档: :ref:`api_fluid_layers_equal` + + + .. _cn_api_fluid_layers_IfElse: IfElse ->>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.IfElse(cond, name=None) @@ -371,14 +382,16 @@ if-else控制流。 -英文版API文档: :ref:`api_fluid_layers_IfElse` + + + .. _cn_api_fluid_layers_increment: increment ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.increment(x, value=1.0, in_place=True) @@ -405,14 +418,16 @@ increment -英文版API文档: :ref:`api_fluid_layers_increment` + + + .. _cn_api_fluid_layers_is_empty: is_empty ->>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.is_empty(x, cond=None, **ignored) @@ -438,14 +453,16 @@ is_empty -英文版API文档: :ref:`api_fluid_layers_is_empty` + + + .. _cn_api_fluid_layers_less_than: less_than ->>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.less_than(x, y, force_cpu=None, cond=None, **ignored) @@ -475,14 +492,16 @@ less_than -英文版API文档: :ref:`api_fluid_layers_less_than` + + + .. _cn_api_fluid_layers_Print: Print ->>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.Print(input, first_n=-1, message=None, summarize=-1, print_tensor_name=True, print_tensor_type=True, print_tensor_shape=True, print_tensor_lod=True, print_phase='both') @@ -517,14 +536,16 @@ Print -英文版API文档: :ref:`api_fluid_layers_Print` + + + .. _cn_api_fluid_layers_reorder_lod_tensor_by_rank: reorder_lod_tensor_by_rank ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.reorder_lod_tensor_by_rank(x, rank_table) @@ -562,14 +583,16 @@ reorder_lod_tensor_by_rank -英文版API文档: :ref:`api_fluid_layers_reorder_lod_tensor_by_rank` + + + .. _cn_api_fluid_layers_StaticRNN: StaticRNN ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.layers.StaticRNN(name=None) @@ -591,14 +614,16 @@ StaticRNN -英文版API文档: :ref:`api_fluid_layers_StaticRNN` + + + .. _cn_api_fluid_layers_Switch: Switch ->>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.Switch (name=None) @@ -645,14 +670,16 @@ Switch类实现的功能十分类似if-elif-else。它可以在学习率调度 -英文版API文档: :ref:`api_fluid_layers_Switch` + + + .. _cn_api_fluid_layers_While: While ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.While (cond, is_test=False, name=None) @@ -683,7 +710,9 @@ While -英文版API文档: :ref:`api_fluid_layers_While` + + + @@ -697,7 +726,7 @@ While .. _cn_api_fluid_layers_batch: batch ->>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.batch(reader, batch_size) @@ -734,14 +763,16 @@ batch -英文版API文档: :ref:`api_fluid_layers_batch` + + + .. _cn_api_fluid_layers_create_py_reader_by_data: create_py_reader_by_data ->>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.create_py_reader_by_data(capacity,feed_list,name=None,use_double_buffer=True) @@ -789,14 +820,16 @@ create_py_reader_by_data -英文版API文档: :ref:`api_fluid_layers_create_py_reader_by_data` + + + .. _cn_api_fluid_layers_data: data ->>>>> +------------------------------- .. py:function:: paddle.fluid.layers.data(name, shape, append_batch_size=True, dtype='float32', lod_level=0, type=VarType.LOD_TENSOR, stop_gradient=True) @@ -835,14 +868,16 @@ data -英文版API文档: :ref:`api_fluid_layers_data` + + + .. _cn_api_fluid_layers_double_buffer: double_buffer ->>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.double_buffer(reader, place=None, name=None) @@ -873,14 +908,16 @@ double_buffer -英文版API文档: :ref:`api_fluid_layers_double_buffer` + + + .. _cn_api_fluid_layers_load: load ->>>>> +------------------------------- .. py:function:: paddle.fluid.layers.load(out, file_path, load_as_fp16=None) @@ -901,14 +938,16 @@ Load操作命令将从磁盘文件中加载LoDTensor/SelectedRows变量。 -英文版API文档: :ref:`api_fluid_layers_load` + + + .. _cn_api_fluid_layers_open_files: open_files ->>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.open_files(filenames, shapes, lod_levels, dtypes, thread_num=None, buffer_size=None, pass_num=1, is_test=None) @@ -945,14 +984,16 @@ open_files -英文版API文档: :ref:`api_fluid_layers_open_files` + + + .. _cn_api_fluid_layers_Preprocessor: Preprocessor ->>>>>>>>>>>>> +------------------------------- .. py:class:: class paddle.fluid.layers.Preprocessor(reader, name=None) @@ -976,14 +1017,16 @@ reader变量中数据预处理块。 -英文版API文档: :ref:`api_fluid_layers_Preprocessor` + + + .. _cn_api_fluid_layers_py_reader: py_reader ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.py_reader(capacity, shapes, dtypes, lod_levels=None, name=None, use_double_buffer=True) @@ -1111,14 +1154,16 @@ py_reader -英文版API文档: :ref:`api_fluid_layers_py_reader` + + + .. _cn_api_fluid_layers_random_data_generator: random_data_generator ->>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.random_data_generator(low, high, shapes, lod_levels, for_parallel=True) @@ -1151,14 +1196,16 @@ random_data_generator -英文版API文档: :ref:`api_fluid_layers_random_data_generator` + + + .. _cn_api_fluid_layers_read_file: read_file ->>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.read_file(reader) @@ -1186,14 +1233,16 @@ reader也是变量。可以为由fluid.layers.open_files()生成的原始reader -英文版API文档: :ref:`api_fluid_layers_read_file` + + + .. _cn_api_fluid_layers_shuffle: shuffle ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.shuffle(reader, buffer_size) @@ -1210,7 +1259,9 @@ shuffle -英文版API文档: :ref:`api_fluid_layers_shuffle` + + + @@ -1224,7 +1275,7 @@ shuffle .. _cn_api_fluid_layers_add_position_encoding: add_position_encoding ->>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.add_position_encoding(input, alpha, beta, name=None) @@ -1236,9 +1287,9 @@ add_position_encoding .. math:: - PE(pos, 2i) = \sin{(pos / 10000^{2i / P})}\\ - PE(pos, 2i + 1) = \cos{(pos / 10000^{2i / P})}\\ - Out(:, pos, i) = \alpha * input(:, pos, i) + \beta * PE(pos, i) + PE(pos, 2i) &= \sin{(pos / 10000^{2i / P})}\\ + PE(pos, 2i + 1) &= \cos{(pos / 10000^{2i / P})}\\ + Out(:, pos, i) &= \alpha * input(:, pos, i) + \beta * PE(pos, i) 其中: - PE(pos, 2i): 偶数位置上数字的增量 @@ -1257,14 +1308,15 @@ add_position_encoding -英文版API文档: :ref:`api_fluid_layers_add_position_encoding` + + .. _cn_api_fluid_layers_affine_channel: affine_channel ->>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.affine_channel(x, scale=None, bias=None, data_layout='NCHW', name=None) @@ -1283,14 +1335,16 @@ affine_channel -英文版API文档: :ref:`api_fluid_layers_affine_channel` + + + .. _cn_api_fluid_layers_affine_grid: affine_grid ->>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.affine_grid(theta, out_shape, name=None) @@ -1387,14 +1441,16 @@ affine_grid -英文版API文档: :ref:`api_fluid_layers_affine_grid` + + + .. _cn_api_fluid_layers_autoincreased_step_counter: autoincreased_step_counter ->>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.autoincreased_step_counter(counter_name=None, begin=1, step=1) @@ -1418,14 +1474,16 @@ autoincreased_step_counter -英文版API文档: :ref:`api_fluid_layers_autoincreased_step_counter` + + + .. _cn_api_fluid_layers_batch_norm: batch_norm ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.batch_norm(input, act=None, is_test=False, momentum=0.9, epsilon=1e-05, param_attr=None, bias_attr=None, data_layout='NCHW', in_place=False, name=None, moving_mean_name=None, moving_variance_name=None, do_model_average_for_mean_and_var=False, fuse_with_relu=False) @@ -1477,14 +1535,16 @@ batch_norm -英文版API文档: :ref:`api_fluid_layers_batch_norm` + + + .. _cn_api_fluid_layers_beam_search: beam_search ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.beam_search(pre_ids, pre_scores, ids, scores, beam_size, end_id, level=0, name=None) @@ -1540,14 +1600,16 @@ beam_search -英文版API文档: :ref:`api_fluid_layers_beam_search` + + + .. _cn_api_fluid_layers_beam_search_decode: beam_search_decode ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.beam_search_decode(ids, scores, beam_size, end_id, name=None) @@ -1580,14 +1642,16 @@ beam_search_decode -英文版API文档: :ref:`api_fluid_layers_beam_search_decode` + + + .. _cn_api_fluid_layers_bilinear_tensor_product: bilinear_tensor_product ->>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.bilinear_tensor_product(x, y, size, act=None, name=None, param_attr=None, bias_attr=None) @@ -1625,14 +1689,16 @@ bilinear_tensor_product -英文版API文档: :ref:`api_fluid_layers_bilinear_tensor_product` + + + .. _cn_api_fluid_layers_brelu: brelu ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.brelu(x, t_min=0.0, t_max=24.0, name=None) @@ -1649,14 +1715,16 @@ BRelu 激活函数 -英文版API文档: :ref:`api_fluid_layers_brelu` + + + .. _cn_api_fluid_layers_chunk_eval: chunk_eval ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.chunk_eval(input, label, chunk_scheme, num_chunk_types, excluded_chunk_types=None) @@ -1743,14 +1811,16 @@ num_tag_type是标注规则中的标签类型数,num_chunk_type是块类型数 -英文版API文档: :ref:`api_fluid_layers_chunk_eval` + + + .. _cn_api_fluid_layers_clip: clip ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.clip(x, min, max, name=None) @@ -1774,14 +1844,16 @@ clip运算符限制给定输入的值在一个区间内。间隔使用参数“m -英文版API文档: :ref:`api_fluid_layers_clip` + + + .. _cn_api_fluid_layers_clip_by_norm: clip_by_norm ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.clip_by_norm(x, max_norm, name=None) @@ -1814,14 +1886,16 @@ ClipByNorm算子 -英文版API文档: :ref:`api_fluid_layers_clip_by_norm` + + + .. _cn_api_fluid_layers_conv2d: conv2d ->>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.conv2d(input, num_filters, filter_size, stride=1, padding=0, dilation=1, groups=None, param_attr=None, bias_attr=None, use_cudnn=True, act=None, name=None) @@ -1893,14 +1967,16 @@ conv2d -英文版API文档: :ref:`api_fluid_layers_conv2d` + + + .. _cn_api_fluid_layers_conv2d_transpose: conv2d_transpose ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.conv2d_transpose(input, num_filters, output_size=None, filter_size=None, padding=0, stride=1, dilation=1, groups=None, param_attr=None, bias_attr=None, use_cudnn=True, act=None, name=None) @@ -1988,14 +2064,16 @@ conv2d_transpose -英文版API文档: :ref:`api_fluid_layers_conv2d_transpose` + + + .. _cn_api_fluid_layers_conv3d: conv3d ->>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.conv3d(input, num_filters, filter_size, stride=1, padding=0, dilation=1, groups=None, param_attr=None, bias_attr=None, use_cudnn=True, act=None, name=None) @@ -2066,14 +2144,16 @@ conv3d -英文版API文档: :ref:`api_fluid_layers_conv3d` + + + .. _cn_api_fluid_layers_conv3d_transpose: conv3d_transpose ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.conv3d_transpose(input, num_filters, output_size=None, filter_size=None, padding=0, stride=1, dilation=1, groups=None, param_attr=None, bias_attr=None, use_cudnn=True, act=None, name=None) @@ -2169,14 +2249,16 @@ conv3d_transpose -英文版API文档: :ref:`api_fluid_layers_conv3d_transpose` + + + .. _cn_api_fluid_layers_cos_sim: cos_sim ->>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.cos_sim(X, Y) @@ -2200,14 +2282,16 @@ cos_sim -英文版API文档: :ref:`api_fluid_layers_cos_sim` + + + .. _cn_api_fluid_layers_crf_decoding: crf_decoding ->>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.crf_decoding(input, param_attr, label=None) @@ -2244,14 +2328,16 @@ crf_decoding -英文版API文档: :ref:`api_fluid_layers_crf_decoding` + + + .. _cn_api_fluid_layers_crop: crop ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.crop(x, shape=None, offsets=None, name=None) @@ -2317,14 +2403,16 @@ crop -英文版API文档: :ref:`api_fluid_layers_crop` + + + .. _cn_api_fluid_layers_cross_entropy: cross_entropy ->>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.cross_entropy(input, label, soft_label=False, ignore_index=-100) @@ -2382,14 +2470,16 @@ cross_entropy -英文版API文档: :ref:`api_fluid_layers_cross_entropy` + + + .. _cn_api_fluid_layers_ctc_greedy_decoder: ctc_greedy_decoder ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.ctc_greedy_decoder(input, blank, name=None) @@ -2448,14 +2538,16 @@ A simple example as below: -英文版API文档: :ref:`api_fluid_layers_ctc_greedy_decoder` + + + .. _cn_api_fluid_layers_dice_loss: dice_loss ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.dice_loss(input, label, epsilon=1e-05) @@ -2488,14 +2580,16 @@ dice_loss定义为: -英文版API文档: :ref:`api_fluid_layers_dice_loss` + + + .. _cn_api_fluid_layers_dropout: dropout ->>>>>>> +------------------------------- .. py:function:: Paddle.fluid.layers.dropout(x,dropout_prob,is_test=False,seed=None,name=None,dropout_implementation='downgrade_in_infer') @@ -2535,14 +2629,16 @@ dropout操作 -英文版API文档: :ref:`api_fluid_layers_dropout` + + + .. _cn_api_fluid_layers_dynamic_gru: dynamic_gru ->>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.dynamic_gru(input, size, param_attr=None, bias_attr=None, is_reverse=False, gate_activation='sigmoid', candidate_activation='tanh', h_0=None) @@ -2613,14 +2709,16 @@ dynamic_gru -英文版API文档: :ref:`api_fluid_layers_dynamic_gru` + + + .. _cn_api_fluid_layers_dynamic_lstm: dynamic_lstm ->>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.dynamic_lstm(input, size, h_0=None, c_0=None, param_attr=None, bias_attr=None, use_peepholes=True, is_reverse=False, gate_activation='sigmoid', cell_activation='tanh', candidate_activation='tanh', dtype='float32', name=None) @@ -2705,14 +2803,16 @@ W 代表了权重矩阵(weight matrix),例如 :math:`W_{xi}` 是从输入门 -英文版API文档: :ref:`api_fluid_layers_dynamic_lstm` + + + .. _cn_api_fluid_layers_dynamic_lstmp: dynamic_lstmp ->>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.dynamic_lstmp(input, size, proj_size, param_attr=None, bias_attr=None, use_peepholes=True, is_reverse=False, gate_activation='sigmoid', cell_activation='tanh', candidate_activation='tanh', proj_activation='tanh', dtype='float32', name=None) 动态LSTMP层(Dynamic LSTMP Layer) @@ -2810,7 +2910,9 @@ LSTMP层(具有循环映射的LSTM)在LSTM层后有一个分离的映射层, -英文版API文档: :ref:`api_fluid_layers_dynamic_lstmp` + + + @@ -2818,7 +2920,7 @@ LSTMP层(具有循环映射的LSTM)在LSTM层后有一个分离的映射层, edit_distance ->>>>>>>>>>>>>> +------------------------------- .. py:function:: Paddle.fluid.layers.edit_distance(input,label,normalized=True,ignored_tokens=None) @@ -2855,14 +2957,16 @@ edit_distance -英文版API文档: :ref:`api_fluid_layers_edit_distance` + + + .. _cn_api_fluid_layers_elementwise_add: elementwise_add ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.elementwise_add(x, y, axis=-1, act=None, name=None) @@ -2909,14 +3013,16 @@ elementwise_add -英文版API文档: :ref:`api_fluid_layers_elementwise_add` + + + .. _cn_api_fluid_layers_elementwise_div: elementwise_div ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.elementwise_div(x, y, axis=-1, act=None, name=None) @@ -2965,14 +3071,16 @@ elementwise_div -英文版API文档: :ref:`api_fluid_layers_elementwise_div` + + + .. _cn_api_fluid_layers_elementwise_max: elementwise_max ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.elementwise_max(x, y, axis=-1, act=None, name=None) 最大元素算子 @@ -3020,14 +3128,16 @@ elementwise_max -英文版API文档: :ref:`api_fluid_layers_elementwise_max` + + + .. _cn_api_fluid_layers_elementwise_min: elementwise_min ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.elementwise_min(x, y, axis=-1, act=None, name=None) @@ -3076,14 +3186,16 @@ elementwise_min -英文版API文档: :ref:`api_fluid_layers_elementwise_min` + + + .. _cn_api_fluid_layers_elementwise_mul: elementwise_mul ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.elementwise_mul(x, y, axis=-1, act=None, name=None) @@ -3131,14 +3243,16 @@ elementwise_mul -英文版API文档: :ref:`api_fluid_layers_elementwise_mul` + + + .. _cn_api_fluid_layers_elementwise_pow: elementwise_pow ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.elementwise_pow(x, y, axis=-1, act=None, name=None) @@ -3187,14 +3301,16 @@ elementwise_pow -英文版API文档: :ref:`api_fluid_layers_elementwise_pow` + + + .. _cn_api_fluid_layers_elementwise_sub: elementwise_sub ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.elementwise_sub(x, y, axis=-1, act=None, name=None) @@ -3242,14 +3358,16 @@ elementwise_sub -英文版API文档: :ref:`api_fluid_layers_elementwise_sub` + + + .. _cn_api_fluid_layers_elu: elu ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.elu(x, alpha=1.0, name=None) @@ -3271,14 +3389,16 @@ ELU激活层(ELU Activation Operator) -英文版API文档: :ref:`api_fluid_layers_elu` + + + .. _cn_api_fluid_layers_embedding: embedding ->>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.embedding(input, size, is_sparse=False, is_distributed=False, padding_idx=None, param_attr=None, dtype='float32') @@ -3310,14 +3430,16 @@ embedding -英文版API文档: :ref:`api_fluid_layers_embedding` + + + .. _cn_api_fluid_layers_expand: expand ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.expand(x, expand_times, name=None) @@ -3359,14 +3481,16 @@ expand运算会按给定的次数对输入各维度进行复制(tile)运算 -英文版API文档: :ref:`api_fluid_layers_expand` + + + .. _cn_api_fluid_layers_fc: fc ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.fc(input, size, num_flatten_dims=1, param_attr=None, bias_attr=None, act=None, is_test=False, name=None) @@ -3422,14 +3546,16 @@ fc -英文版API文档: :ref:`api_fluid_layers_fc` + + + .. _cn_api_fluid_layers_flatten: flatten ->>>>>>>>>> +------------------------------- 将输入张量压扁成二维矩阵 @@ -3476,14 +3602,16 @@ flatten -英文版API文档: :ref:`api_fluid_layers_flatten` + + + .. _cn_api_fluid_layers_gather: gather ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.gather(input, index) @@ -3522,14 +3650,16 @@ gather -英文版API文档: :ref:`api_fluid_layers_gather` + + + .. _cn_api_fluid_layers_gaussian_random: gaussian_random ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.gaussian_random(shape, mean=0.0, std=1.0, seed=0, dtype='float32') @@ -3551,14 +3681,16 @@ gaussian_random算子。 -英文版API文档: :ref:`api_fluid_layers_gaussian_random` + + + .. _cn_api_fluid_layers_gaussian_random_batch_size_like: gaussian_random_batch_size_like ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.gaussian_random_batch_size_like(input, shape, input_dim_idx=0, output_dim_idx=0, mean=0.0, std=1.0, seed=0, dtype='float32') @@ -3581,14 +3713,43 @@ gaussian_random_batch_size_like -英文版API文档: :ref:`api_fluid_layers_gaussian_random_batch_size_like` + + + + + + +.. _cn_api_fluid_layers_get_tensor_from_selected_rows: + +get_tensor_from_selected_rows +------------------------------- + +.. py:function:: paddle.fluid.layers.get_tensor_from_selected_rows(x, name=None) + +:code:`Get Tensor From Selected Rows` 用于从选中行(Selected Rows)中获取张量 + +参数: + - **x** (Variable) - 输入,类型是SelectedRows + - **name** (basestring|None) - 输出的名称 + +返回: 输出类型为LoDTensor + +返回类型: out(Variable) + + + + + + + + .. _cn_api_fluid_layers_grid_sampler: grid_sampler ->>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.grid_sampler(x, grid, name=None) @@ -3656,14 +3817,16 @@ step 2: -英文版API文档: :ref:`api_fluid_layers_grid_sampler` + + + .. _cn_api_fluid_layers_group_norm: group_norm ->>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.group_norm(input, groups, epsilon=1e-05, param_attr=None, bias_attr=None, act=None, data_layout='NCHW', name=None) @@ -3692,14 +3855,16 @@ group_norm -英文版API文档: :ref:`api_fluid_layers_group_norm` + + + .. _cn_api_fluid_layers_gru_unit: gru_unit ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.gru_unit(input, hidden, size, param_attr=None, bias_attr=None, activation='tanh', gate_activation='sigmoid') @@ -3758,14 +3923,16 @@ GRU单元的输入包括 :math:`z_t` , :math:`h_{t-1}` 。在上述等式中 -英文版API文档: :ref:`api_fluid_layers_gru_unit` + + + .. _cn_api_fluid_layers_hard_sigmoid: hard_sigmoid ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.hard_sigmoid(x, slope=0.2, offset=0.5, name=None) @@ -3787,14 +3954,16 @@ sigmoid的分段线性逼近(https://arxiv.org/abs/1603.00391),比sigmoid快 -英文版API文档: :ref:`api_fluid_layers_hard_sigmoid` + + + .. _cn_api_fluid_layers_hash: hash ->>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.hash(input, hash_size, num_hash=1, name=None) @@ -3858,14 +4027,16 @@ hash -英文版API文档: :ref:`api_fluid_layers_hash` + + + .. _cn_api_fluid_layers_hsigmoid: hsigmoid ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.hsigmoid(input, label, num_functiones, param_attr=None, bias_attr=None, name=None) @@ -3897,14 +4068,16 @@ hsigmoid -英文版API文档: :ref:`api_fluid_layers_hsigmoid` + + + .. _cn_api_fluid_layers_im2sequence: im2sequence ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.im2sequence(input, filter_size=1, stride=1, padding=0, input_image_size=None, out_stride=1, name=None) @@ -3983,14 +4156,16 @@ im2sequence -英文版API文档: :ref:`api_fluid_layers_im2sequence` + + + .. _cn_api_fluid_layers_image_resize: image_resize ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.image_resize(input, out_shape=None, scale=None, name=None, resample='BILINEAR') @@ -4023,14 +4198,16 @@ image_resize -英文版API文档: :ref:`api_fluid_layers_image_resize` + + + .. _cn_api_fluid_layers_image_resize_short: image_resize_short ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.image_resize_short(input, out_short_len, resample='BILINEAR') @@ -4049,14 +4226,16 @@ image_resize_short -英文版API文档: :ref:`api_fluid_layers_image_resize_short` + + + .. _cn_api_fluid_layers_l2_normalize: l2_normalize ->>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.l2_normalize(x,axis,epsilon=1e-12,name=None) @@ -4091,14 +4270,16 @@ L2正则(L2 normalize Layer) -英文版API文档: :ref:`api_fluid_layers_l2_normalize` + + + .. _cn_api_fluid_layers_label_smooth: label_smooth ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.label_smooth(label, prior_dist=None, epsilon=0.1, dtype='float32', name=None) @@ -4138,14 +4319,16 @@ label_smooth -英文版API文档: :ref:`api_fluid_layers_label_smooth` + + + .. _cn_api_fluid_layers_layer_norm: layer_norm ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.layer_norm(input, scale=True, shift=True, begin_norm_axis=1, epsilon=1e-05, param_attr=None, bias_attr=None, act=None, name=None) @@ -4191,14 +4374,16 @@ layer_norm -英文版API文档: :ref:`api_fluid_layers_layer_norm` + + + .. _cn_api_fluid_layers_leaky_relu: leaky_relu ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.leaky_relu(x, alpha=0.02, name=None) @@ -4213,14 +4398,16 @@ LeakyRelu 激活函数 -英文版API文档: :ref:`api_fluid_layers_leaky_relu` + + + .. _cn_api_fluid_layers_linear_chain_crf: linear_chain_crf ->>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.linear_chain_crf(input, label, param_attr=None) @@ -4282,14 +4469,16 @@ linear_chain_crf -英文版API文档: :ref:`api_fluid_layers_linear_chain_crf` + + + .. _cn_api_fluid_layers_lod_reset: lod_reset ->>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.lod_reset(x, y=None, target_lod=None) @@ -4367,14 +4556,16 @@ lod_reset -英文版API文档: :ref:`api_fluid_layers_lod_reset` + + + .. _cn_api_fluid_layers_log: log ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.log(x, name=None) @@ -4404,14 +4595,16 @@ log -英文版API文档: :ref:`api_fluid_layers_log` + + + .. _cn_api_fluid_layers_log_loss: log_loss ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.log_loss(input, label, epsilon=0.0001, name=None) @@ -4446,14 +4639,16 @@ log_loss -英文版API文档: :ref:`api_fluid_layers_log_loss` + + + .. _cn_api_fluid_layers_logical_and: logical_and ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.logical_and(x, y, out=None, name=None) @@ -4477,14 +4672,16 @@ logical_and算子 -英文版API文档: :ref:`api_fluid_layers_logical_and` + + + .. _cn_api_fluid_layers_logical_not: logical_not ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.logical_not(x, out=None, name=None) @@ -4507,14 +4704,16 @@ logical_not算子 -英文版API文档: :ref:`api_fluid_layers_logical_not` + + + .. _cn_api_fluid_layers_logical_or: logical_or ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.logical_or(x, y, out=None, name=None) @@ -4538,14 +4737,16 @@ logical_or算子 -英文版API文档: :ref:`api_fluid_layers_logical_or` + + + .. _cn_api_fluid_layers_logical_xor: logical_xor ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.logical_xor(x, y, out=None, name=None) @@ -4569,14 +4770,16 @@ logical_xor算子 -英文版API文档: :ref:`api_fluid_layers_logical_xor` + + + .. _cn_api_fluid_layers_lrn: lrn ->>>> +------------------------------- .. py:function:: paddle.fluid.layers.lrn(input, n=5, k=1.0, alpha=0.0001, beta=0.75, name=None) @@ -4623,14 +4826,93 @@ lrn -英文版API文档: :ref:`api_fluid_layers_lrn` + + + + + + +.. _cn_api_fluid_layers_lstm: + +lstm +------------------------------- + +.. py:function:: paddle.fluid.layers.lstm(input, init_h, init_c, max_len, hidden_size, num_layers, dropout_prob=0.0, is_bidirec=False, is_test=False, name=None, default_initializer=None, seed=-1) + +如果您的设备是GPU,本op将使用cudnn LSTM实现 + +一个没有 peephole 连接的四门长短期记忆网络。在前向传播中,给定迭代的输出ht和单元输出ct可由递归输入ht-1、单元输入ct-1和上一层输入xt计算,给定矩阵W、R和bias bW, bR由下式计算: + +.. math:: + + i_t = \sigma(W_{ix}x_{t} + W_{ih}h_{t-1} + bx_i + bh_i)\\ + f_t = \sigma(W_{fx}x_{t} + W_{fh}h_{t-1} + bx_f + bh_f)\\ + o_t = \sigma(W_{ox}x_{t} + W_{oh}h_{t-1} + bx_o + bh_o)\\ + \tilde{c_t} = tanh(W_{cx}x_t + W_{ch}h_{t-1} + bx_c + bh_c)\\ + c_t = f_t \odot c_{t-1} + i_t \odot \tilde{c_t}\\ + h_t = o_t \odot tanh(c_t) + +公式中: + - W 项表示权重矩阵(e.g. :math:`W_{ix}` 是从输入门到输入的权重矩阵) + - b 项表示偏差向量( :math:`b_{xi}` 和 :math:`b_{hi}` 是输入门的偏差向量) + - sigmoid 是 logistic sigmoid 函数 + - i、f、o、c 分别为输入门、遗忘门、输出门和激活向量,它们的大小与 cell 输出激活向量h相同。 + - :math:`\odot` 是向量的元素乘积 + - tanh是激活函数 + - :math:`\tilde{c_t}` 也称为候选隐藏状态,它是根据当前输入和之前的隐藏状态来计算的 + - sigmoid的计算公式为:sigmoid(x) = 1 / (1 + e^-x) + - \*表示点乘,X表示矩阵乘 + +参数: + - **input** (Variable) - LSTM 输入张量,形状必须为(seq_len x,batch_size,x,input_size) + - **init_h** (Variable) – LSTM的初始隐藏状态,是一个有形状的张量(num_layers,x,batch_size,x,hidden_size)如果is_bidirec = True,形状应该是(num_layers*2,x, batch_size, x, hidden_size) + - **init_c** (Variable) - LSTM的初始状态。这是一个有形状的张量(num_layers, x, batch_size, x, hidden_size)如果is_bidirec = True,形状应该是(num_layers*2, x, batch_size, x, hidden_size) + - **max_len** (int) – LSTM的最大长度。输入张量的第一个 dim 不能大于max_len + - **hidden_size** (int) - LSTM的隐藏大小 + - **num_layers** (int) – LSTM的总层数 + - **dropout_prob** (float|0.0) – dropout prob,dropout 只在 rnn 层之间工作,而不是在时间步骤之间。dropout 不作用于最后的 rnn 层的 rnn 输出中 + - **is_bidirec** (bool) – 是否是双向的 + - **is_test** (bool) – 是否在测试阶段 + - **name** (str|None) - 此层的名称(可选)。如果没有设置,该层将被自动命名。 + - **default_initializer** (Initialize|None) – 在哪里使用初始化器初始化权重,如果没有设置,将进行默认初始化。 + - **seed** (int) – LSTM中dropout的Seed,如果是-1,dropout将使用随机Seed + +返回: + - LSTM hidden的结果:形状(seq_len x batch_size x hidden_size)如果is_bidirec设置为True,形状为(seq_len x batch_sze hidden_size * 2) + - last_h(Tensor): LSTM最后一步的隐藏状态,形状为(num_layers x batch_size x hidden_size);如果is_bidirec设置为True,形状为(num_layers*2 x batch_size x hidden_size) + - last_c(Tensor): LSTM最后一步的cell状态,形状为(num_layers x batch_size x hidden_size);如果is_bidirec设置为True,形状为(num_layers*2 x batch_size x hidden_size) + +**代码示例:** + +.. code-block:: python + + input = embedding + batch_size = 20 + max_len = 100 + dropout_prob = 0.2 + input_size = 100 + hidden_size = 150 + num_layers = 1 + init_hidden1 = layers.fill_constant( [num_layers, batch_size, hidden_size], 'float32', 0.0, stop_grad=False) + init_cell1 = layers.fill_constant( [num_layers, batch_size, hidden_size], 'float32', 0.0, stop_grad=False) + + rnn_out, last_h, last_c = layers.lstm( input, init_h, init_c, max_len, dropout_prob, input_size, hidden_size, num_layers) + + + + + + + + + .. _cn_api_fluid_layers_lstm_unit: lstm_unit ->>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.lstm_unit(x_t, hidden_t_prev, cell_t_prev, forget_bias=0.0, param_attr=None, bias_attr=None, name=None) @@ -4691,14 +4973,16 @@ lstm单元的输入包括 :math:`x_{t}` , :math:`h_{t-1}` 和 :math:`c_{t-1}` -英文版API文档: :ref:`api_fluid_layers_lstm_unit` + + + .. _cn_api_fluid_layers_margin_rank_loss: margin_rank_loss ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.margin_rank_loss(label, left, right, margin=0.1, name=None) @@ -4737,7 +5021,9 @@ margin rank loss(差距排序损失)层。在排序问题中,它可以比 -英文版API文档: :ref:`api_fluid_layers_margin_rank_loss` + + + @@ -4746,7 +5032,7 @@ margin rank loss(差距排序损失)层。在排序问题中,它可以比 matmul ->>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.matmul(x, y, transpose_x=False, transpose_y=False, alpha=1.0, name=None) @@ -4804,14 +5090,16 @@ matmul -英文版API文档: :ref:`api_fluid_layers_matmul` + + + .. _cn_api_fluid_layers_maxout: maxout ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.maxout(x, groups, name=None) @@ -4843,14 +5131,16 @@ maxout -英文版API文档: :ref:`api_fluid_layers_maxout` + + + .. _cn_api_fluid_layers_mean: mean ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.mean(x, name=None) @@ -4867,14 +5157,16 @@ mean算子计算X中所有元素的平均值 -英文版API文档: :ref:`api_fluid_layers_mean` + + + .. _cn_api_fluid_layers_mean_iou: mean_iou ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.mean_iou(input, label, num_functiones) @@ -4901,14 +5193,62 @@ mean_iou -英文版API文档: :ref:`api_fluid_layers_mean_iou` + + + + + + +.. _cn_api_fluid_layers_merge_selected_rows: + +merge_selected_rows +------------------------------- + +.. py:function:: paddle.fluid.layers.merge_selected_rows(x, name=None) + +**实现合并选中行(row)操作** + +该运算用于合并(值相加)输入张量中重复的行。输出行没有重复的行,并且按值从小到大顺序重新对行排序。 + +:: + + 例如: + + 输入: + X.rows = [0, 5, 5, 4, 19] + X.height = 20 + X.value = [[1, 1] [2, 2] [3, 3] [4, 4] [6, 6]] + + + 输出: + Out.row is [0, 4, 5, 19] + Out.height is 20 + Out.value is: [[1, 1] [4, 4] [5, 5] [6, 6]] + + + +参数: + - x (Variable) – 输入类型为SelectedRows, 选中行有可能重复 + - name (basestring|None) – 输出变量的命名 + +返回: 输出类型为SelectedRows,并且选中行不会重复 + +返回类型: 变量(Variable) + + + + + + + + .. _cn_api_fluid_layers_mul: mul ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.mul(x, y, x_num_col_dims=1, y_num_col_dims=1, name=None) @@ -4935,14 +5275,16 @@ mul算子 -英文版API文档: :ref:`api_fluid_layers_mul` + + + .. _cn_api_fluid_layers_multiplex: multiplex ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.multiplex(inputs, index) @@ -4989,14 +5331,16 @@ multiplex -英文版API文档: :ref:`api_fluid_layers_multiplex` + + + .. _cn_api_fluid_layers_nce: nce ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.nce(input, label, num_total_functiones, sample_weight=None, param_attr=None, bias_attr=None, num_neg_samples=None, name=None) @@ -5050,14 +5394,16 @@ nce -英文版API文档: :ref:`api_fluid_layers_nce` + + + .. _cn_api_fluid_layers_one_hot: one_hot ->>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.one_hot(input, depth) @@ -5080,14 +5426,16 @@ one_hot -英文版API文档: :ref:`api_fluid_layers_one_hot` + + + .. _cn_api_fluid_layers_pad: pad ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.pad(x, paddings, pad_value=0.0, name=None) @@ -5134,14 +5482,16 @@ pad -英文版API文档: :ref:`api_fluid_layers_pad` + + + .. _cn_api_fluid_layers_pad2d: pad2d ->>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.pad2d(input, paddings=[0, 0, 0, 0], mode='constant', pad_value=0.0, data_format='NCHW', name=None) @@ -5202,14 +5552,16 @@ pad2d -英文版API文档: :ref:`api_fluid_layers_pad2d` + + + .. _cn_api_fluid_layers_pad_constant_like: pad_constant_like ->>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.pad_constant_like(x, y, pad_value=0.0, name=None) @@ -5262,14 +5614,16 @@ pad_constant_like -英文版API文档: :ref:`api_fluid_layers_pad_constant_like` + + + .. _cn_api_fluid_layers_pool2d: pool2d ->>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.pool2d(input, pool_size=-1, pool_type='max', pool_stride=1, pool_padding=0, global_pooling=False, use_cudnn=True, ceil_mode=False, name=None) @@ -5358,14 +5712,16 @@ pooling2d操作符根据 ``input`` , 池化类型 ``pool_type`` , 池化核 -英文版API文档: :ref:`api_fluid_layers_pool2d` + + + .. _cn_api_fluid_layers_pool3d: pool3d ->>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.pool3d(input, pool_size=-1, pool_type='max', pool_stride=1, pool_padding=0, global_pooling=False, use_cudnn=True, ceil_mode=False, name=None) @@ -5391,14 +5747,16 @@ pool3d -英文版API文档: :ref:`api_fluid_layers_pool3d` + + + .. _cn_api_fluid_layers_pow: pow ->>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.pow(x, factor=1.0, name=None) @@ -5415,14 +5773,16 @@ pow -英文版API文档: :ref:`api_fluid_layers_pow` + + + .. _cn_api_fluid_layers_prelu: prelu ->>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.prelu(x, mode, param_attr=None, name=None) @@ -5445,14 +5805,16 @@ prelu -英文版API文档: :ref:`api_fluid_layers_prelu` + + + .. _cn_api_fluid_layers_random_crop: random_crop ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.random_crop(x, shape, seed=None) @@ -5475,14 +5837,16 @@ random_crop -英文版API文档: :ref:`api_fluid_layers_random_crop` + + + .. _cn_api_fluid_layers_rank_loss: rank_loss ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.rank_loss(label, left, right, name=None) @@ -5527,14 +5891,16 @@ P 的取值可为: {0, 1} 或 {0, 0.5, 1}, 其中,0.5表示输入的两文 -英文版API文档: :ref:`api_fluid_layers_rank_loss` + + + .. _cn_api_fluid_layers_reduce_max: reduce_max ->>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.reduce_max(input, dim=None, keep_dim=False, name=None) @@ -5573,14 +5939,16 @@ reduce_max -英文版API文档: :ref:`api_fluid_layers_reduce_max` + + + .. _cn_api_fluid_layers_reduce_mean: reduce_mean ->>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.reduce_mean(input, dim=None, keep_dim=False, name=None) @@ -5620,14 +5988,16 @@ reduce_mean -英文版API文档: :ref:`api_fluid_layers_reduce_mean` + + + .. _cn_api_fluid_layers_reduce_min: reduce_min ->>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.reduce_min(input, dim=None, keep_dim=False, name=None) @@ -5666,14 +6036,16 @@ reduce_min -英文版API文档: :ref:`api_fluid_layers_reduce_min` + + + .. _cn_api_fluid_layers_reduce_prod: reduce_prod ->>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.reduce_prod(input, dim=None, keep_dim=False, name=None) @@ -5713,14 +6085,16 @@ reduce_prod -英文版API文档: :ref:`api_fluid_layers_reduce_prod` + + + .. _cn_api_fluid_layers_reduce_sum: reduce_sum ->>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.reduce_sum(input, dim=None, keep_dim=False, name=None) @@ -5759,14 +6133,16 @@ reduce_sum -英文版API文档: :ref:`api_fluid_layers_reduce_sum` + + + .. _cn_api_fluid_layers_relu: relu ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.relu(x, name=None) @@ -5793,14 +6169,16 @@ Relu接受一个输入数据(张量),输出一个张量。将线性函数y = m -英文版API文档: :ref:`api_fluid_layers_relu` + + + .. _cn_api_fluid_layers_relu6: relu6 ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.relu6(x, threshold=6.0, name=None) @@ -5823,14 +6201,16 @@ relu6激活算子(Relu6 Activation Operator) -英文版API文档: :ref:`api_fluid_layers_relu6` + + + .. _cn_api_fluid_layers_reshape: reshape ->>>>>>>>>> +------------------------------- 保持输入张量数据不变的情况下,改变张量的形状。 @@ -5877,14 +6257,16 @@ reshape -英文版API文档: :ref:`api_fluid_layers_reshape` + + + .. _cn_api_fluid_layers_resize_bilinear: resize_bilinear ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.resize_bilinear(input, out_shape=None, scale=None, name=None) @@ -5904,14 +6286,16 @@ resize_bilinear -英文版API文档: :ref:`api_fluid_layers_resize_bilinear` + + + .. _cn_api_fluid_layers_resize_nearest: resize_nearest ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.resize_nearest(input, out_shape=None, scale=None, name=None, actual_shape=None) @@ -5940,14 +6324,16 @@ resize_nearest -英文版API文档: :ref:`api_fluid_layers_resize_nearest` + + + .. _cn_api_fluid_layers_roi_align: roi_align ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.roi_align(input, rois, pooled_height=1, pooled_width=1, spatial_scale=1.0, sampling_ratio=-1, name=None) @@ -5987,14 +6373,16 @@ Region of Interests align(直译:有意义、有价值选区对齐) 用于实 -英文版API文档: :ref:`api_fluid_layers_roi_align` + + + .. _cn_api_fluid_layers_roi_pool: roi_pool ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.roi_pool(input, rois, pooled_height=1, pooled_width=1, spatial_scale=1.0) @@ -6030,14 +6418,16 @@ Faster-RCNN.使用了roi池化。roi关于roi池化请参考 https://stackoverfl -英文版API文档: :ref:`api_fluid_layers_roi_pool` + + + .. _cn_api_fluid_layers_row_conv: row_conv ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.row_conv(input, future_context_size, param_attr=None, act=None) @@ -6082,14 +6472,16 @@ row_conv -英文版API文档: :ref:`api_fluid_layers_row_conv` + + + .. _cn_api_fluid_layers_sampling_id: sampling_id ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sampling_id(x, min=0.0, max=1.0, seed=0, dtype='float32') @@ -6110,14 +6502,16 @@ sampling_id算子。用于从输入的多项分布中对id进行采样的图层 -英文版API文档: :ref:`api_fluid_layers_sampling_id` + + + .. _cn_api_fluid_layers_scale: scale ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.scale(x, scale=1.0, bias=0.0, bias_after_scale=True, act=None, name=None) @@ -6150,14 +6544,16 @@ else: -英文版API文档: :ref:`api_fluid_layers_scale` + + + .. _cn_api_fluid_layers_scatter: scatter ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.scatter(input, index, updates, name=None) @@ -6188,14 +6584,16 @@ scatter -英文版API文档: :ref:`api_fluid_layers_scatter` + + + .. _cn_api_fluid_layers_selu: selu ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.selu(x, scale=None, alpha=None, name=None) @@ -6234,14 +6632,16 @@ selu -英文版API文档: :ref:`api_fluid_layers_selu` + + + .. _cn_api_fluid_layers_sequence_concat: sequence_concat ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sequence_concat(input, name=None) @@ -6265,14 +6665,16 @@ sequence_concat操作通过序列信息连接LoD张量(Tensor)。例如:X1 -英文版API文档: :ref:`api_fluid_layers_sequence_concat` + + + .. _cn_api_fluid_layers_sequence_conv: sequence_conv ->>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sequence_conv(input, num_filters, filter_size=3, filter_stride=1, padding=None, bias_attr=None, param_attr=None, act=None, name=None) @@ -6294,14 +6696,16 @@ sequence_conv -英文版API文档: :ref:`api_fluid_layers_sequence_conv` + + + .. _cn_api_fluid_layers_sequence_enumerate: sequence_enumerate ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sequence_enumerate(input, win_size, pad_value=0, name=None) @@ -6336,14 +6740,16 @@ sequence_enumerate -英文版API文档: :ref:`api_fluid_layers_sequence_enumerate` + + + .. _cn_api_fluid_layers_sequence_expand: sequence_expand ->>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sequence_expand(x, y, ref_level=-1, name=None) @@ -6406,14 +6812,16 @@ sequence_expand -英文版API文档: :ref:`api_fluid_layers_sequence_expand` + + + .. _cn_api_fluid_layers_sequence_expand_as: sequence_expand_as ->>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sequence_expand_as(x, y, name=None) @@ -6457,14 +6865,16 @@ Sequence Expand As Layer -英文版API文档: :ref:`api_fluid_layers_sequence_expand_as` + + + .. _cn_api_fluid_layers_sequence_first_step: sequence_first_step ->>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sequence_first_step(input) @@ -6500,14 +6910,16 @@ sequence_first_step -英文版API文档: :ref:`api_fluid_layers_sequence_first_step` + + + .. _cn_api_fluid_layers_sequence_last_step: sequence_last_step ->>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sequence_last_step(input) @@ -6545,14 +6957,16 @@ sequence_last_step -英文版API文档: :ref:`api_fluid_layers_sequence_last_step` + + + .. _cn_api_fluid_layers_sequence_mask: sequence_mask ->>>>>>>>>>>>>> +------------------------------- 该层根据输入 ``x`` 和 ```maxlen`` 输出一个掩码,数据类型为dtype。 @@ -6577,14 +6991,16 @@ sequence_mask -英文版API文档: :ref:`api_fluid_layers_sequence_mask` + + + .. _cn_api_fluid_layers_sequence_pad: sequence_pad ->>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sequence_pad(x,pad_value,maxlen=None) @@ -6667,14 +7083,16 @@ sequence_pad -英文版API文档: :ref:`api_fluid_layers_sequence_pad` + + + .. _cn_api_fluid_layers_sequence_pool: sequence_pool ->>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sequence_pool(input, pool_type) @@ -6727,14 +7145,16 @@ sequence_pool -英文版API文档: :ref:`api_fluid_layers_sequence_pool` + + + .. _cn_api_fluid_layers_sequence_reshape: sequence_reshape ->>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sequence_reshape(input, new_dim) @@ -6777,14 +7197,16 @@ Sequence Reshape Layer -英文版API文档: :ref:`api_fluid_layers_sequence_reshape` + + + .. _cn_api_fluid_layers_sequence_reverse: sequence_reverse ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sequence_reverse(x, name=None) @@ -6824,14 +7246,16 @@ sequence_reverse -英文版API文档: :ref:`api_fluid_layers_sequence_reverse` + + + .. _cn_api_fluid_layers_sequence_scatter: sequence_scatter ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sequence_scatter(input, index, updates, name=None) @@ -6879,14 +7303,16 @@ sequence_scatter -英文版API文档: :ref:`api_fluid_layers_sequence_scatter` + + + .. _cn_api_fluid_layers_sequence_slice: sequence_slice ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sequence_slice(input, offset, length, name=None) @@ -6939,14 +7365,16 @@ sequence_slice -英文版API文档: :ref:`api_fluid_layers_sequence_slice` + + + .. _cn_api_fluid_layers_sequence_softmax: sequence_softmax ->>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sequence_softmax(input, use_cudnn=False, name=None) @@ -6982,14 +7410,16 @@ sequence_softmax -英文版API文档: :ref:`api_fluid_layers_sequence_softmax` + + + .. _cn_api_fluid_layers_sequence_unpad: sequence_unpad ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sequence_unpad(x, length, name=None) @@ -7039,14 +7469,16 @@ sequence_unpad -英文版API文档: :ref:`api_fluid_layers_sequence_unpad` + + + .. _cn_api_fluid_layers_shape: shape ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.shape(input) @@ -7065,14 +7497,16 @@ shape算子 -英文版API文档: :ref:`api_fluid_layers_shape` + + + .. _cn_api_fluid_layers_sigmoid_cross_entropy_with_logits: sigmoid_cross_entropy_with_logits ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sigmoid_cross_entropy_with_logits(x, label, name=None) @@ -7116,14 +7550,16 @@ sigmoid_cross_entropy_with_logits -英文版API文档: :ref:`api_fluid_layers_sigmoid_cross_entropy_with_logits` + + + .. _cn_api_fluid_layers_similarity_focus: similarity_focus ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.similarity_focus(input, axis, indexes, name=None) @@ -7213,14 +7649,16 @@ similarity_focus -英文版API文档: :ref:`api_fluid_layers_similarity_focus` + + + .. _cn_api_fluid_layers_slice: slice ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.slice(input, axes, starts, ends) @@ -7257,14 +7695,16 @@ slice算子。 -英文版API文档: :ref:`api_fluid_layers_slice` + + + .. _cn_api_fluid_layers_smooth_l1: smooth_l1 ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.smooth_l1(x, y, inside_weight=None, outside_weight=None, sigma=None) @@ -7295,14 +7735,16 @@ smooth_l1 -英文版API文档: :ref:`api_fluid_layers_smooth_l1` + + + .. _cn_api_fluid_layers_soft_relu: soft_relu ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.soft_relu(x, threshold=40.0, name=None) @@ -7318,14 +7760,16 @@ SoftRelu 激活函数 -英文版API文档: :ref:`api_fluid_layers_soft_relu` + + + .. _cn_api_fluid_layers_softmax: softmax ->>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.softmax(input, use_cudnn=True, name=None) @@ -7361,14 +7805,16 @@ softmax操作符计算k维向量输入中所有其他维的指数和指数值的 -英文版API文档: :ref:`api_fluid_layers_softmax` + + + .. _cn_api_fluid_layers_softmax_with_cross_entropy: softmax_with_cross_entropy ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.softmax_with_cross_entropy(logits, label, soft_label=False, ignore_index=-100) @@ -7415,14 +7861,16 @@ softmax_with_cross_entropy -英文版API文档: :ref:`api_fluid_layers_softmax_with_cross_entropy` + + + .. _cn_api_fluid_layers_space_to_depth: space_to_depth ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.space_to_depth(x, blocksize, name=None) @@ -7465,14 +7913,16 @@ space_to_depth -英文版API文档: :ref:`api_fluid_layers_space_to_depth` + + + .. _cn_api_fluid_layers_split: split ->>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.split(input,num_or_sections,dim=-1,name=None) @@ -7505,14 +7955,16 @@ split -英文版API文档: :ref:`api_fluid_layers_split` + + + .. _cn_api_fluid_layers_square_error_cost: square_error_cost ->>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.square_error_cost(input,label) @@ -7549,14 +8001,16 @@ square_error_cost -英文版API文档: :ref:`api_fluid_layers_square_error_cost` + + + .. _cn_api_fluid_layers_squeeze: squeeze ->>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.squeeze(input, axes, name=None) @@ -7598,14 +8052,16 @@ squeeze -英文版API文档: :ref:`api_fluid_layers_squeeze` + + + .. _cn_api_fluid_layers_stack: stack ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.stack(x, axis=0) @@ -7627,14 +8083,16 @@ stack -英文版API文档: :ref:`api_fluid_layers_stack` + + + .. _cn_api_fluid_layers_stanh: stanh ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.stanh(x, scale_a=0.6666666666666666, scale_b=1.7159, name=None) @@ -7655,14 +8113,16 @@ STanh 激活算子(STanh Activation Operator.) -英文版API文档: :ref:`api_fluid_layers_stanh` + + + .. _cn_api_fluid_layers_sum: sum ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sum(x) @@ -7680,14 +8140,16 @@ sum算子。 -英文版API文档: :ref:`api_fluid_layers_sum` + + + .. _cn_api_fluid_layers_swish: swish ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.swish(x, beta=1.0, name=None) @@ -7710,14 +8172,16 @@ Swish 激活函数 -英文版API文档: :ref:`api_fluid_layers_swish` + + + .. _cn_api_fluid_layers_topk: topk ->>>>> +------------------------------- .. py:function:: paddle.fluid.layers.topk(input, k, name=None) 这个运算符用于查找最后一维的前k个最大项,返回它们的值和索引。 @@ -7766,14 +8230,16 @@ topk -英文版API文档: :ref:`api_fluid_layers_topk` + + + .. _cn_api_fluid_layers_transpose: transpose ->>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.transpose(x,perm,name=None) @@ -7799,14 +8265,16 @@ transpose -英文版API文档: :ref:`api_fluid_layers_transpose` + + + .. _cn_api_fluid_layers_uniform_random_batch_size_like: uniform_random_batch_size_like ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.uniform_random_batch_size_like(input, shape, dtype='float32', input_dim_idx=0, output_dim_idx=0, min=-1.0, max=1.0, seed=0) @@ -7830,14 +8298,16 @@ uniform_random_batch_size_like算子。 -英文版API文档: :ref:`api_fluid_layers_uniform_random_batch_size_like` + + + .. _cn_api_fluid_layers_unsqueeze: unsqueeze ->>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.unsqueeze(input, axes, name=None) @@ -7865,14 +8335,16 @@ unsqueeze -英文版API文档: :ref:`api_fluid_layers_unsqueeze` + + + .. _cn_api_fluid_layers_unstack: unstack ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.unstack(x, axis=0, num=None) @@ -7899,14 +8371,16 @@ unstack -英文版API文档: :ref:`api_fluid_layers_unstack` + + + .. _cn_api_fluid_layers_warpctc: warpctc ->>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.warpctc(input, label, blank=0, norm_by_times=False, use_cudnn=False)) @@ -7933,7 +8407,9 @@ warpctc -英文版API文档: :ref:`api_fluid_layers_warpctc` + + + @@ -7947,7 +8423,7 @@ warpctc .. _cn_api_fluid_layers_abs: abs ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.abs(x, name=None) @@ -7963,14 +8439,16 @@ abs -英文版API文档: :ref:`api_fluid_layers_abs` + + + .. _cn_api_fluid_layers_ceil: ceil ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.ceil(x, name=None) @@ -7984,14 +8462,16 @@ ceil -英文版API文档: :ref:`api_fluid_layers_ceil` + + + .. _cn_api_fluid_layers_cos: cos ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.cos(x, name=None) @@ -8006,14 +8486,16 @@ cos -英文版API文档: :ref:`api_fluid_layers_cos` + + + .. _cn_api_fluid_layers_cumsum: cumsum ->>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.cumsum(x,axis=None,exclusive=None,reverse=None @@ -8036,14 +8518,16 @@ cumsum -英文版API文档: :ref:`api_fluid_layers_cumsum` + + + .. _cn_api_fluid_layers_exp: exp ->>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.exp(x, name=None) @@ -8057,14 +8541,16 @@ exp -英文版API文档: :ref:`api_fluid_layers_exp` + + + .. _cn_api_fluid_layers_floor: floor ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.floor(x, name=None) @@ -8080,14 +8566,16 @@ floor -英文版API文档: :ref:`api_fluid_layers_floor` + + + .. _cn_api_fluid_layers_hard_shrink: hard_shrink ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.hard_shrink(x,threshold=None) @@ -8117,14 +8605,16 @@ HardShrink激活函数(HardShrink activation operator) -英文版API文档: :ref:`api_fluid_layers_hard_shrink` + + + .. _cn_api_fluid_layers_logsigmoid: logsigmoid ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.logsigmoid(x, name=None) @@ -8139,14 +8629,16 @@ logsigmoid -英文版API文档: :ref:`api_fluid_layers_logsigmoid` + + + .. _cn_api_fluid_layers_reciprocal: reciprocal ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.reciprocal(x, name=None) @@ -8163,14 +8655,16 @@ reciprocal -英文版API文档: :ref:`api_fluid_layers_reciprocal` + + + .. _cn_api_fluid_layers_round: round ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.round(x, name=None) @@ -8184,14 +8678,16 @@ round -英文版API文档: :ref:`api_fluid_layers_round` + + + .. _cn_api_fluid_layers_sigmoid: sigmoid ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sigmoid(x, name=None) @@ -8207,14 +8703,16 @@ sigmoid -英文版API文档: :ref:`api_fluid_layers_sigmoid` + + + .. _cn_api_fluid_layers_sin: sin ->>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sin(x, name=None) @@ -8229,14 +8727,16 @@ sin -英文版API文档: :ref:`api_fluid_layers_sin` + + + .. _cn_api_fluid_layers_softplus: softplus ->>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.softplus(x,name=None) @@ -8248,14 +8748,16 @@ softplus -英文版API文档: :ref:`api_fluid_layers_softplus` + + + .. _cn_api_fluid_layers_softshrink: softshrink ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.softshrink(x, name=None) @@ -8277,14 +8779,16 @@ Softshrink激活算子 -英文版API文档: :ref:`api_fluid_layers_softshrink` + + + .. _cn_api_fluid_layers_softsign: softsign ->>>>>>>>> +------------------------------- .. py:function:: Paddle.fluid.layers.softsign(x,name=None) @@ -8296,14 +8800,16 @@ softsign -英文版API文档: :ref:`api_fluid_layers_softsign` + + + .. _cn_api_fluid_layers_sqrt: sqrt ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sqrt(x, name=None) @@ -8318,14 +8824,16 @@ sqrt -英文版API文档: :ref:`api_fluid_layers_sqrt` + + + .. _cn_api_fluid_layers_square: square ->>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.square(x,name=None) @@ -8337,14 +8845,16 @@ square -英文版API文档: :ref:`api_fluid_layers_square` + + + .. _cn_api_fluid_layers_tanh: tanh ->>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.tanh(x, name=None) @@ -8361,14 +8871,16 @@ tanh -英文版API文档: :ref:`api_fluid_layers_tanh` + + + .. _cn_api_fluid_layers_tanh_shrink: tanh_shrink ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.tanh_shrink(x, name=None) @@ -8381,14 +8893,16 @@ tanh_shrink -英文版API文档: :ref:`api_fluid_layers_tanh_shrink` + + + .. _cn_api_fluid_layers_thresholded_relu: thresholded_relu ->>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.thresholded_relu(x,threshold=None) @@ -8416,14 +8930,16 @@ thresholded_relu -英文版API文档: :ref:`api_fluid_layers_thresholded_relu` + + + .. _cn_api_fluid_layers_uniform_random: uniform_random ->>>>>>>>>>>>>> +------------------------------- .. py:function:: Paddle.fluid.layers.uniform_random(shape,dtype=None,min=None,max=None,seed=None) 该操作符初始化一个张量,该张量的值是从正太分布中抽样的随机值 @@ -8445,7 +8961,9 @@ uniform_random -英文版API文档: :ref:`api_fluid_layers_uniform_random` + + + @@ -8459,7 +8977,7 @@ uniform_random .. _cn_api_fluid_layers_argmax: argmax ->>>>>> +------------------------------- .. py:function:: paddle.fluid.layers argmin(x,axis=0) @@ -8484,14 +9002,16 @@ argmax -英文版API文档: :ref:`api_fluid_layers_argmax` + + + .. _cn_api_fluid_layers_argmin: argmin ->>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers argmin(x,axis=0) @@ -8516,14 +9036,16 @@ argmin -英文版API文档: :ref:`api_fluid_layers_argmin` + + + .. _cn_api_fluid_layers_argsort: argsort ->>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers argsort(input,axis=-1,name=None) @@ -8565,14 +9087,16 @@ argsort -英文版API文档: :ref:`api_fluid_layers_argsort` + + + .. _cn_api_fluid_layers_assign: assign ->>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.assign(input,output=None) @@ -8598,14 +9122,16 @@ assign -英文版API文档: :ref:`api_fluid_layers_assign` + + + .. _cn_api_fluid_layers_cast: cast ->>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.cast(x,dtype) @@ -8628,14 +9154,16 @@ cast -英文版API文档: :ref:`api_fluid_layers_cast` + + + .. _cn_api_fluid_layers_concat: concat ->>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.concat(input,axis=0,name=None) @@ -8660,14 +9188,16 @@ concat -英文版API文档: :ref:`api_fluid_layers_concat` + + + .. _cn_api_fluid_layers_create_global_var: create_global_var ->>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.create_global_var(shape,value,dtype,persistable=False,force_cpu=False,name=None) @@ -8694,14 +9224,16 @@ create_global_var -英文版API文档: :ref:`api_fluid_layers_create_global_var` + + + .. _cn_api_fluid_layers_create_parameter: create_parameter ->>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.create_parameter(shape,dtype,name=None,attr=None,is_bias=False,default_initializer=None) @@ -8728,14 +9260,16 @@ create_parameter -英文版API文档: :ref:`api_fluid_layers_create_parameter` + + + .. _cn_api_fluid_layers_create_tensor: create_tensor ->>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.create_tensor(dtype,name=None,persistable=False) @@ -8757,14 +9291,18 @@ create_tensor tensor = fluid.layers.create_tensor(dtype='float32') -英文版API文档: :ref:`api_fluid_layers_create_tensor` + + + + + .. _cn_api_fluid_layers_fill_constant: fill_constant ->>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers fill_constant(shape,dtype,value,force_cpu=False,out=None) @@ -8793,14 +9331,16 @@ fill_constant -英文版API文档: :ref:`api_fluid_layers_fill_constant` + + + .. _cn_api_fluid_layers_fill_constant_batch_size_like: fill_constant_batch_size_like ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.fill_constant_batch_size_like(input,shape,dtype,value,input_dim_idx=0,output_dim_idx=0) @@ -8826,14 +9366,16 @@ fill_constant_batch_size_like -英文版API文档: :ref:`api_fluid_layers_fill_constant_batch_size_like` + + + .. _cn_api_fluid_layers_has_inf: has_inf ->>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.has_inf(x) @@ -8853,14 +9395,16 @@ has_inf -英文版API文档: :ref:`api_fluid_layers_has_inf` + + + .. _cn_api_fluid_layers_has_nan: has_nan ->>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.has_nan(x) @@ -8874,14 +9418,16 @@ has_nan -英文版API文档: :ref:`api_fluid_layers_has_nan` + + + .. _cn_api_fluid_layers_isfinite: isfinite ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.isfinite(x) @@ -8896,14 +9442,16 @@ isfinite -英文版API文档: :ref:`api_fluid_layers_isfinite` + + + .. _cn_api_fluid_layers_ones: ones ->>>>> +------------------------------- .. py:function:: paddle.fluid.layers.ones(shape,dtype,force_cpu=False) @@ -8929,14 +9477,16 @@ ones -英文版API文档: :ref:`api_fluid_layers_ones` + + + .. _cn_api_fluid_layers_reverse: reverse ->>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.reverse(x,axis) @@ -8962,14 +9512,16 @@ reverse -英文版API文档: :ref:`api_fluid_layers_reverse` + + + .. _cn_api_fluid_layers_sums: sums ->>>>> +------------------------------- .. py:function:: paddle.fluid.layers.sums(input,out=None) @@ -8998,14 +9550,16 @@ sums -英文版API文档: :ref:`api_fluid_layers_sums` + + + .. _cn_api_fluid_layers_tensor_array_to_tensor: tensor_array_to_tensor ->>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.tensor_array_to_tensor(input, axis=1, name=None) @@ -9049,14 +9603,16 @@ tensor_array_to_tensor -英文版API文档: :ref:`api_fluid_layers_tensor_array_to_tensor` + + + .. _cn_api_fluid_layers_zeros: zeros ->>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.zeros(shape,dtype,force_cpu=False) @@ -9082,7 +9638,9 @@ zeros -英文版API文档: :ref:`api_fluid_layers_zeros` + + + @@ -9096,7 +9654,7 @@ zeros .. _cn_api_fluid_layers_append_LARS: append_LARS ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.append_LARS(params_grads,learning_rate,weight_decay) @@ -9117,14 +9675,16 @@ append_LARS -英文版API文档: :ref:`api_fluid_layers_append_LARS` + + + .. _cn_api_fluid_layers_exponential_decay: exponential_decay ->>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers exponential_decay(learning_rate,decay_steps,decay_rate,staircase=False) @@ -9163,14 +9723,16 @@ exponential_decay -英文版API文档: :ref:`api_fluid_layers_exponential_decay` + + + .. _cn_api_fluid_layers_inverse_time_decay: inverse_time_decay ->>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.inverse_time_decay(learning_rate, decay_steps, decay_rate, staircase=False) @@ -9210,14 +9772,16 @@ inverse_time_decay -英文版API文档: :ref:`api_fluid_layers_inverse_time_decay` + + + .. _cn_api_fluid_layers_natural_exp_decay: natural_exp_decay ->>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.natural_exp_decay(learning_rate, decay_steps, decay_rate, staircase=False) @@ -9240,14 +9804,16 @@ natural_exp_decay -英文版API文档: :ref:`api_fluid_layers_natural_exp_decay` + + + .. _cn_api_fluid_layers_noam_decay: noam_decay ->>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers noam_decay(d_model,warmup_steps) @@ -9270,14 +9836,16 @@ Noam衰减方法。noam衰减的numpy实现如下。 -英文版API文档: :ref:`api_fluid_layers_noam_decay` + + + .. _cn_api_fluid_layers_piecewise_decay: piecewise_decay ->>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.piecewise_decay(boundaries,values) @@ -9304,14 +9872,16 @@ piecewise_decay -英文版API文档: :ref:`api_fluid_layers_piecewise_decay` + + + .. _cn_api_fluid_layers_polynomial_decay: polynomial_decay ->>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.polynomial_decay(learning_rate,decay_steps,end_learning_rate=0.0001,power=1.0,cycle=False) @@ -9339,7 +9909,9 @@ polynomial_decay -英文版API文档: :ref:`api_fluid_layers_polynomial_decay` + + + @@ -9353,7 +9925,7 @@ polynomial_decay .. _cn_api_fluid_layers_anchor_generator: anchor_generator ->>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.anchor_generator(input, anchor_sizes=None, aspect_ratios=None, variance=[0.1, 0.1, 0.2, 0.2], stride=None, offset=0.5, name=None) @@ -9401,14 +9973,16 @@ anchor_generator -英文版API文档: :ref:`api_fluid_layers_anchor_generator` + + + .. _cn_api_fluid_layers_bipartite_match: bipartite_match ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.bipartite_match(dist_matrix, match_type=None, dist_threshold=None, name=None) @@ -9452,14 +10026,16 @@ bipartite_match -英文版API文档: :ref:`api_fluid_layers_bipartite_match` + + + .. _cn_api_fluid_layers_box_coder: box_coder ->>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.box_coder(prior_box, prior_box_var, target_box, code_type='encode_center_size', box_normalized=True, name=None) @@ -9511,14 +10087,16 @@ Bounding Box Coder -英文版API文档: :ref:`api_fluid_layers_box_coder` + + + .. _cn_api_fluid_layers_density_prior_box: density_prior_box ->>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.density_prior_box(input, image, densities=None, fixed_sizes=None, fixed_ratios=None, variance=[0.1, 0.1, 0.2, 0.2], clip=False, steps=[0.0, 0.0], offset=0.5, flatten_to_2d=False, name=None) @@ -9589,14 +10167,16 @@ density prior box的量由fixed_sizes and fixed_ratios决定。显然地,fixed -英文版API文档: :ref:`api_fluid_layers_density_prior_box` + + + .. _cn_api_fluid_layers_detection_map: detection_map ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.detection_map(detect_res, label, function_num, background_label=0, overlap_threshold=0.3, evaluate_difficult=True, has_state=None, input_states=None, out_states=None, ap_version='integral') @@ -9654,14 +10234,16 @@ detection_map -英文版API文档: :ref:`api_fluid_layers_detection_map` + + + .. _cn_api_fluid_layers_detection_output: detection_output ->>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.detection_output(loc, scores, prior_box, prior_box_var, background_label=0, nms_threshold=0.3, nms_top_k=400, keep_top_k=200, score_threshold=0.01, nms_eta=1.0) @@ -9713,14 +10295,16 @@ Detection Output Layer for Single Shot Multibox Detector(SSD) -英文版API文档: :ref:`api_fluid_layers_detection_output` + + + .. _cn_api_fluid_layers_generate_proposal_labels: generate_proposal_labels ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.generate_proposal_labels(rpn_rois, gt_functiones, is_crowd, gt_boxes, im_info, batch_size_per_im=256, fg_fraction=0.25, fg_thresh=0.25, bg_thresh_hi=0.5, bg_thresh_lo=0.0, bbox_reg_weights=[0.1, 0.1, 0.2, 0.2], function_nums=None, use_random=True) @@ -9758,14 +10342,16 @@ RpnRois 是RPN的输出box, 并由 ``GenerateProposals`` 来进一步处理, -英文版API文档: :ref:`api_fluid_layers_generate_proposal_labels` + + + .. _cn_api_fluid_layers_generate_proposals: generate_proposals ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.generate_proposals(scores, bbox_deltas, im_info, anchors, variances, pre_nms_top_n=6000, post_nms_top_n=1000, nms_thresh=0.5, min_size=0.1, eta=1.0, name=None) @@ -9801,14 +10387,17 @@ generate_proposals -英文版API文档: :ref:`api_fluid_layers_generate_proposals` + + + + .. _cn_api_fluid_layers_iou_similarity: iou_similarity ->>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.iou_similarity(x, y, name=None) @@ -9830,14 +10419,16 @@ iou_similarity -英文版API文档: :ref:`api_fluid_layers_iou_similarity` + + + .. _cn_api_fluid_layers_multi_box_head: multi_box_head ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.multi_box_head(inputs, image, base_size, num_functiones, aspect_ratios, min_ratio=None, max_ratio=None, min_sizes=None, max_sizes=None, steps=None, step_w=None, step_h=None, offset=0.5, variance=[0.1, 0.1, 0.2, 0.2], flip=True, clip=False, kernel_size=1, pad=0, stride=1, name=None, min_max_aspect_ratios_order=False) @@ -9897,14 +10488,16 @@ multi_box_head -英文版API文档: :ref:`api_fluid_layers_multi_box_head` + + + .. _cn_api_fluid_layers_polygon_box_transform: polygon_box_transform ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.polygon_box_transform(input, name=None) @@ -9925,14 +10518,16 @@ PolygonBoxTransform 算子。 -英文版API文档: :ref:`api_fluid_layers_polygon_box_transform` + + + .. _cn_api_fluid_layers_prior_box: prior_box ->>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.prior_box(input,image,min_sizes=None,aspect_ratios=[1.0],variance=[0.1,0.1,0.2,0.2],flip=False,clip=False,steps=[0.0,0.0],offset=0.5,name=None,min_max_aspect_ratios_order=False) **Prior Box Operator** @@ -9975,14 +10570,16 @@ prior_box -英文版API文档: :ref:`api_fluid_layers_prior_box` + + + .. _cn_api_fluid_layers_roi_perspective_transform: roi_perspective_transform ->>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.roi_perspective_transform(input, rois, transformed_height, transformed_width, spatial_scale=1.0) @@ -10015,14 +10612,16 @@ roi_perspective_transform -英文版API文档: :ref:`api_fluid_layers_roi_perspective_transform` + + + .. _cn_api_fluid_layers_rpn_target_assign: rpn_target_assign ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.rpn_target_assign(bbox_pred, cls_logits, anchor_box, anchor_var, gt_boxes, is_crowd, im_info, rpn_batch_size_per_im=256, rpn_straddle_thresh=0.0, rpn_fg_fraction=0.5, rpn_positive_overlap=0.7, rpn_negative_overlap=0.3, use_random=True) @@ -10075,14 +10674,16 @@ rpn_target_assign -英文版API文档: :ref:`api_fluid_layers_rpn_target_assign` + + + .. _cn_api_fluid_layers_ssd_loss: ssd_loss ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.ssd_loss(location, confidence, gt_box, gt_label, prior_box, prior_box_var=None, background_label=0, overlap_threshold=0.5, neg_pos_ratio=3.0, neg_overlap=0.5, loc_loss_weight=1.0, conf_loss_weight=1.0, match_type='per_prediction', mining_type='max_negative', normalize=True, sample_size=None) @@ -10167,14 +10768,16 @@ ssd_loss -英文版API文档: :ref:`api_fluid_layers_ssd_loss` + + + .. _cn_api_fluid_layers_target_assign: target_assign ->>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.target_assign(input, matched_indices, negative_indices=None, mismatch_value=None, name=None) @@ -10227,7 +10830,9 @@ target_assign -英文版API文档: :ref:`api_fluid_layers_target_assign` + + + @@ -10241,7 +10846,7 @@ target_assign .. _cn_api_fluid_layers_accuracy: accuracy ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.layers.accuracy(input, label, k=1, correct=None, total=None) @@ -10274,14 +10879,16 @@ accuracy layer。 参考 https://en.wikipedia.org/wiki/Precision_and_recall -英文版API文档: :ref:`api_fluid_layers_accuracy` + + + .. _cn_api_fluid_layers_auc: auc ->>>>> +------------------------------- .. py:function:: paddle.fluid.layers.auc(input, label, curve='ROC', num_thresholds=4095, topk=1, slide_steps=1) @@ -10320,7 +10927,9 @@ auc -英文版API文档: :ref:`api_fluid_layers_auc` + + + diff --git a/doc/fluid/api_cn/metrics_cn.rst b/doc/fluid/api_cn/metrics_cn.rst index 4ba6a470bf02b136f8926e28354dfa875b237539..ab7c8b6e83983f4abe9ef6e192431600a9743d20 100644 --- a/doc/fluid/api_cn/metrics_cn.rst +++ b/doc/fluid/api_cn/metrics_cn.rst @@ -1,142 +1,98 @@ - ################# fluid.metrics ################# -.. _cn_api_fluid_merics_Auc: - -Auc ->>>> - -.. py:class:: paddle.fluid.metrics.Auc(name, curve='ROC', num_thresholds=4095) +.. _cn_api_fluid_metrics_Accuracy: -Auc度量适用于二分类。参考 https://en.wikipedia.org/wiki/Receiver_operating_characteristic#Area_under_the_curve 。需要注意auc度量本身是用Python计算值。如果关心速度,请用fluid.layers.auc。 +Accuracy +------------------------------- -auc函数创建四个局部变量true_positives, true_negatives, false_positives和false_negatives,用于计算AUC。对于离散化AUC曲线,临界值线性间隔设置以便计算召回率和准确率的值,用false positive率的召回值高度计算ROC曲线面积,用recall的准确值高度计算PR曲线面积。 +.. py:class:: paddle.fluid.metrics.Accuracy(name=None) -参数: - - **name** - 度量名 - - **curve** - 将要计算的曲线名的详情,曲线包括ROC(默认)或者PR(Precision-Recall-curve)。 +累加mini-batch正确率,计算每次pass的平均准确率。https://en.wikipedia.org/wiki/Accuracy_and_precision -注:目前只用Python实现ROC曲线 +参数: + - **name** — 度量标准的名称 -**代码示例**: +**代码示例** .. code-block:: python + labels = fluid.layers.data(name="data", shape=[1], dtype="int32") + data = fluid.layers.data(name="data", shape=[32, 32], dtype="int32") pred = fluid.layers.fc(input=data, size=1000, act="tanh") - metric = fluid.metrics.Auc() - for data in train_reader(): - loss, preds, labels = exe.run(fetch_list=[cost, preds, labels]) - metric.update(preds, labels) - numpy_auc = metric.eval() - - - - - - - - - + minibatch_accuracy = fluid.layers.accuracy(pred, label) + accuracy_evaluator = fluid.metrics.Accuracy() + for pass in range(PASSES): + accuracy_evaluator.reset() + for data in train_reader(): + batch_size = data[0] + loss = exe.run(fetch_list=[cost, minibatch_accuracy]) + accuracy_evaluator.update(value=minibatch_accuracy, weight=batch_size) + numpy_acc = accuracy_evaluator.eval() -英文版API文档: :ref:`api_fluid_merics_Auc` -.. _cn_api_fluid_merics_MetricBase: +.. py:method:: update(value, weight) -MetricBase ->>>>>>>>>>>> +更新mini batch的状态. -.. py:class:: paddle.fluid.metrics.MetricBase(name) +参数: + - **value** (float|numpy.array) – 每个mini batch的正确率 + - **weight** (int|float) – batch 大小 -所有Metrics的基类。MetricBase为模型估计方法定义一组接口。Metrics累积连续的两个minibatch之间的度量状态,对每个minibatch用最新接口将当前minibatch值添加到全局状态。用eval函数来计算last reset()或者scratch on()中累积的度量值。如果需要定制一个新的metric,请继承自MetricBase和自定义实现类。 -参数: - - **name** (str) - metric实例名。例如准确率(accuracy)。如果想区分一个模型里不同的metrics,则需要实例名。 -.. py:method:: reset() - reset()清除度量(metric)的状态(state)。默认情况下,状态(state)包含没有 ``_`` 前缀的metric。reset将这些状态设置为初始状态。如果不想使用隐式命名规则,请自定义reset接口。 -.. py:method:: get_config() -获取度量(metric)状态和当前状态。状态(state)包含没有 ``_`` 前缀的成员。 - -参数:**None** -返回:metric对应到state的字典 +.. _cn_api_fluid_metrics_Auc: -返回类型:字典(dict) +Auc +------------------------------- +.. py:class:: paddle.fluid.metrics.Auc(name, curve='ROC', num_thresholds=4095) -.. py:method:: update(preds,labels) +Auc度量适用于二分类。参考 https://en.wikipedia.org/wiki/Receiver_operating_characteristic#Area_under_the_curve 。需要注意auc度量本身是用Python计算值。如果关心速度,请用fluid.layers.auc。 -更新每个minibatch的度量状态(metric states),用户可通过Python或者C++操作符计算minibatch度量值(metric)。 +auc函数创建四个局部变量true_positives, true_negatives, false_positives和false_negatives,用于计算AUC。对于离散化AUC曲线,临界值线性间隔设置以便计算召回率和准确率的值,用false positive率的召回值高度计算ROC曲线面积,用recall的准确值高度计算PR曲线面积。 参数: - - **preds** (numpy.array) - 当前minibatch的预测 - - **labels** (numpy.array) - 当前minibatch的标签,如果标签为one-hot或者soft-label,应该自定义相应的更新规则。 - -.. py:method:: eval() - -基于累积状态(accumulated states)评估当前度量(current metric)。 - -返回:metrics(Python中) - -返回类型:float|list(float)|numpy.array - + - **name** - 度量名 + - **curve** - 将要计算的曲线名的详情,曲线包括ROC(默认)或者PR(Precision-Recall-curve)。 +注:目前只用Python实现ROC曲线 -英文版API文档: :ref:`api_fluid_merics_MetricBase` +**代码示例**: -.. _cn_api_fluid_metrics_Accuracy: +.. code-block:: python -Accuracy ->>>>>>>>>>>> + pred = fluid.layers.fc(input=data, size=1000, act="tanh") + metric = fluid.metrics.Auc() + for data in train_reader(): + loss, preds, labels = exe.run(fetch_list=[cost, preds, labels]) + metric.update(preds, labels) + numpy_auc = metric.eval() -.. py:class:: paddle.fluid.metrics.Accuracy(name=None) -累加mini-batch正确率,计算每次pass的平均准确率。https://en.wikipedia.org/wiki/Accuracy_and_precision -参数: - - **name** — 度量标准的名称 -**代码示例** -.. code-block:: python - labels = fluid.layers.data(name="data", shape=[1], dtype="int32") - data = fluid.layers.data(name="data", shape=[32, 32], dtype="int32") - pred = fluid.layers.fc(input=data, size=1000, act="tanh") - minibatch_accuracy = fluid.layers.accuracy(pred, label) - accuracy_evaluator = fluid.metrics.Accuracy() - for pass in range(PASSES): - accuracy_evaluator.reset() - for data in train_reader(): - batch_size = data[0] - loss = exe.run(fetch_list=[cost, minibatch_accuracy]) - accuracy_evaluator.update(value=minibatch_accuracy, weight=batch_size) - numpy_acc = accuracy_evaluator.eval() -.. py:method:: update(value, weight) -更新mini batch的状态. -参数: - - **value** (float|numpy.array) – 每个mini batch的正确率 - - **weight** (int|float) – batch 大小 -英文版API文档: :ref:`api_fluid_metrics_Accuracy` .. _cn_api_fluid_metrics_ChunkEvaluator: ChunkEvaluator ->>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.metrics.ChunkEvaluator(name=None) @@ -169,12 +125,14 @@ ChunkEvaluator -英文版API文档: :ref:`api_fluid_metrics_ChunkEvaluator` + + + .. _cn_api_fluid_metrics_CompositeMetric: CompositeMetric ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.metrics.CompositeMetric(name=None) @@ -229,14 +187,16 @@ CompositeMetric -英文版API文档: :ref:`api_fluid_metrics_CompositeMetric` + + + .. _cn_api_fluid_metrics_DetectionMAP: DetectionMAP ->>>>>>>>>>>> +------------------------------- -.. py:class:: class paddle.fluid.metrics.DetectionMAP(name=None) +.. py:class:: paddle.fluid.metrics.DetectionMAP(name=None) 计算 detection 平均精度(mAP)。 mAP是衡量object detectors精度的指标,比如 Faster R-CNN,SSD等。它不同于召回率,它是最大精度的平均值。 请从以下文章中获取更多信息: @@ -275,12 +235,14 @@ https://arxiv.org/abs/1512.02325 -英文版API文档: :ref:`api_fluid_metrics_DetectionMAP` + + + .. _cn_api_fluid_metrics_EditDistance: EditDistance ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.metrics.EditDistance(name) @@ -307,12 +269,63 @@ EditDistance -英文版API文档: :ref:`api_fluid_metrics_EditDistance` + + + + +.. _cn_api_fluid_metrics_MetricBase: + +MetricBase +------------------------------- + +.. py:class:: paddle.fluid.metrics.MetricBase(name) + +所有Metrics的基类。MetricBase为模型估计方法定义一组接口。Metrics累积连续的两个minibatch之间的度量状态,对每个minibatch用最新接口将当前minibatch值添加到全局状态。用eval函数来计算last reset()或者scratch on()中累积的度量值。如果需要定制一个新的metric,请继承自MetricBase和自定义实现类。 + +参数: + - **name** (str) - metric实例名。例如准确率(accuracy)。如果想区分一个模型里不同的metrics,则需要实例名。 + +.. py:method:: reset() + + reset()清除度量(metric)的状态(state)。默认情况下,状态(state)包含没有 ``_`` 前缀的metric。reset将这些状态设置为初始状态。如果不想使用隐式命名规则,请自定义reset接口。 + +.. py:method:: get_config() + +获取度量(metric)状态和当前状态。状态(state)包含没有 ``_`` 前缀的成员。 + +参数:**None** + +返回:metric对应到state的字典 + +返回类型:字典(dict) + + +.. py:method:: update(preds,labels) + +更新每个minibatch的度量状态(metric states),用户可通过Python或者C++操作符计算minibatch度量值(metric)。 + +参数: + - **preds** (numpy.array) - 当前minibatch的预测 + - **labels** (numpy.array) - 当前minibatch的标签,如果标签为one-hot或者soft-label,应该自定义相应的更新规则。 + +.. py:method:: eval() + +基于累积状态(accumulated states)评估当前度量(current metric)。 + +返回:metrics(Python中) + +返回类型:float|list(float)|numpy.array + + + + + + .. _cn_api_fluid_metrics_Precision: Precision ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.metrics.Precision(name=None) @@ -339,12 +352,14 @@ Precision(也称为 positive predictive value,正预测值)是被预测为正样 -英文版API文档: :ref:`api_fluid_metrics_Precision` + + + .. _cn_api_fluid_metrics_Recall: Recall ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.metrics.Recall(name=None) @@ -368,5 +383,7 @@ https://en.wikipedia.org/wiki/Precision_and_recall -英文版API文档: :ref:`api_fluid_metrics_Recall` + + + diff --git a/doc/fluid/api_cn/nets_cn.rst b/doc/fluid/api_cn/nets_cn.rst new file mode 100644 index 0000000000000000000000000000000000000000..338657ad04388bf09f73863b7c37f1ed8cccd85b --- /dev/null +++ b/doc/fluid/api_cn/nets_cn.rst @@ -0,0 +1,253 @@ +################# + fluid.nets +################# + + + +.. _cn_api_fluid_nets_glu: + +glu +------------------------------- +.. py:function:: paddle.fluid.nets.glu(input, dim=-1) +T +he Gated Linear Units(GLU)由切分(split),sigmoid激活函数和按元素相乘组成。沿着给定维将input拆分成两个大小相同的部分,a和b,计算如下: + +.. math:: + + GLU(a,b) = a\bigotimes \sigma (b) + +参考论文: `Language Modeling with Gated Convolutional Networks `_ + +参数: + - **input** (Variable) - 输入变量,张量或者LoDTensor + - **dim** (int) - 拆分的维度。如果 :math:`dim<0`,拆分的维为 :math:`rank(input)+dim`。默认为-1 + +返回:变量 —— 变量的大小为输入的一半 + +返回类型:变量(Variable) + +**代码示例:** + +.. code-block:: python + + data = fluid.layers.data(name="words", shape=[3, 6, 9], dtype="float32") + output = fluid.nets.glu(input=data, dim=1) # shape of output: [3, 3, 9] + + + + + + + + + +.. _cn_api_fluid_nets_img_conv_group: + +img_conv_group +------------------------------- + +.. py:function:: paddle.fluid.nets.img_conv_group(input, conv_num_filter, pool_size, conv_padding=1, conv_filter_size=3, conv_act=None, param_attr=None, conv_with_batchnorm=False, conv_batchnorm_drop_rate=0.0, pool_stride=1, pool_type='max', use_cudnn=True) + +Image Convolution Group由Convolution2d,BatchNorm,DropOut和Pool2d组成。根据输入参数,img_conv_group将使用Convolution2d,BatchNorm,DropOut对Input进行连续计算,并将最后一个结果传递给Pool2d。 + +参数: + - **input** (Variable) - 具有[N,C,H,W]格式的输入图像。 + - **conv_num_filter** (list | tuple) - 表示该组的过滤器数。 + - **pool_size** (int | list | tuple) - ``Pool2d Layer`` 池的大小。如果pool_size是列表或元组,则它必须包含两个整数(pool_size_H,pool_size_W)。否则,pool_size_H = pool_size_W = pool_size。 + - **conv_padding** (int | list | tuple) - Conv2d Layer的 ``padding`` 大小。如果 ``padding`` 是列表或元组,则其长度必须等于 ``conv_num_filter`` 的长度。否则,所有Conv2d图层的 ``conv_padding`` 都是相同的。默认1。 + - **conv_filter_size** (int | list | tuple) - 过滤器大小。如果filter_size是列表或元组,则其长度必须等于 ``conv_num_filter`` 的长度。否则,所有Conv2d图层的 ``conv_filter_size`` 都是相同的。默认3。 + - **conv_act** (str) - ``Conv2d Layer`` 的激活类型, ``BatchNorm`` 后面没有。默认值:无。 + - **param_attr** (ParamAttr) - Conv2d层的参数。默认值:无 + - **conv_with_batchnorm** (bool | list) - 表示在 ``Conv2d Layer`` 之后是否使用 ``BatchNorm`` 。如果 ``conv_with_batchnorm`` 是一个列表,则其长度必须等于 ``conv_num_filter`` 的长度。否则, ``conv_with_batchnorm`` 指示是否所有Conv2d层都遵循 ``BatchNorm``。默认为False。 + - **conv_batchnorm_drop_rate** (float | list) - 表示 ``BatchNorm`` 之后的 ``Dropout Layer`` 的 ``rop_rate`` 。如果 ``conv_batchnorm_drop_rate`` 是一个列表,则其长度必须等于 ``conv_num_filter`` 的长度。否则,所有 ``Dropout Layers`` 的 ``drop_rate`` 都是 ``conv_batchnorm_drop_rate`` 。默认值为0.0。 + - **pool_stride** (int | list | tuple) - ``Pool2d`` 层的汇集步幅。如果 ``pool_stride`` 是列表或元组,则它必须包含两个整数(pooling_stride_H,pooling_stride_W)。否则,pooling_stride_H = pooling_stride_W = pool_stride。默认1。 + - **pool_type** (str) - 池化类型可以是最大池化的 ``max`` 和平均池化的 ``avg`` 。默认max。 + - **use_cudnn** (bool) - 是否使用cudnn内核,仅在安装cudnn库时才有效。默认值:True + +返回: 使用Convolution2d进行串行计算后的最终结果,BatchNorm,DropOut和Pool2d。 + +返回类型: 变量(Variable)。 + +**代码示例** + +.. code-block:: python + + img = fluid.layers.data(name='img', shape=[1, 28, 28], dtype='float32') + conv_pool = fluid.nets.img_conv_group(input=img, + num_channels=3, + conv_padding=1, + conv_num_filter=[3, 3], + conv_filter_size=3, + conv_act="relu", + pool_size=2, + pool_stride=2) + + + + + + + +.. _cn_api_fluid_nets_scaled_dot_product_attention: + +scaled_dot_product_attention +------------------------------- + +.. py:function:: paddle.fluid.nets.scaled_dot_product_attention(queries, keys, values, num_heads=1, dropout_rate=0.0) + +点乘attention运算。 + +attention运算机制可以被视为将查询和一组键值对映射到输出。 将输出计算为值的加权和,其中分配给每个值的权重由查询的兼容性函数(此处的点积)与对应的密钥计算。 + +可以通过(batch)矩阵乘法实现点积attention运算,如下所示: + +.. math:: + Attention(Q, K, V)= softmax(QK^\mathrm{T})V + +请参阅 `Attention Is All You Need `_ + +参数: + - **queries** (Variable) - 输入变量,应为3-D Tensor。 + - **keys** (Variable) - 输入变量,应为3-D Tensor。 + - **values** (Variable) - 输入变量,应为3-D Tensor。 + - **num_heads** (int) - 计算缩放点积attention运算的head数。默认值:1。 + - **dropout_rate** (float) - 降低attention的dropout率。默认值:0.0。 + +返回: 通过multi-head来缩放点积attention运算的三维张量。 + +返回类型: 变量(Variable)。 + +抛出异常: + - ``ValueError`` - 如果输入查询键,值不是3-D Tensor会报错。 + +.. note:: + 当num_heads> 1时,分别学习三个线性投影,以将输入查询,键和值映射到查询',键'和值'。 查询',键'和值'与查询,键和值具有相同的形状。 + 当num_heads == 1时,scaled_dot_product_attention没有可学习的参数。 + +**代码示例** + +.. code-block:: python + + queries = fluid.layers.data(name="queries", + shape=[3, 5, 9], + dtype="float32", + append_batch_size=False) + queries.stop_gradient = False + keys = fluid.layers.data(name="keys", + shape=[3, 6, 9], + dtype="float32", + append_batch_size=False) + keys.stop_gradient = False + values = fluid.layers.data(name="values", + shape=[3, 6, 10], + dtype="float32", + append_batch_size=False) + values.stop_gradient = False + contexts = fluid.nets.scaled_dot_product_attention(queries, keys, values) + contexts.shape # [3, 5, 10] + + + + + + + + + +.. _cn_api_fluid_nets_sequence_conv_pool: + +sequence_conv_pool +------------------------------- + +.. py:function:: paddle.fluid.nets.sequence_conv_pool(input, num_filters, filter_size, param_attr=None, act='sigmoid', pool_type='max') + +sequence_conv_pool由序列卷积和池化组成 + +参数: + - **input** (Variable) - sequence_conv的输入,支持变量时间长度输入序列。当前输入为shape为(T,N)的矩阵,T是mini-batch中的总时间步数,N是input_hidden_size + - **num_filters** (int)- 滤波器数 + - **filter_size** (int)- 滤波器大小 + - **param_attr** (ParamAttr) - Sequence_conv层的参数。默认:None + - **act** (str) - Sequence_conv层的激活函数类型。默认:sigmoid + - **pool_type** (str)- 池化类型。可以是max-pooling的max,average-pooling的average,sum-pooling的sum,sqrt-pooling的sqrt。默认max + +返回:序列卷积(Sequence Convolution)和池化(Pooling)的结果 + + +返回类型:变量(Variable) + +**代码示例**: + +.. code-block:: python + + input_dim = len(word_dict) + emb_dim = 128 + hid_dim = 512 + data = fluid.layers.data( ame="words", shape=[1], dtype="int64", lod_level=1) + emb = fluid.layers.embedding(input=data, size=[input_dim, emb_dim], is_sparse=True) + seq_conv = fluid.nets.sequence_conv_pool(input=emb, + num_filters=hid_dim, + filter_size=3, + act="tanh", + pool_type="sqrt") + + + + + + + + +.. _cn_api_fluid_nets_simple_img_conv_pool: + +simple_img_conv_pool +------------------------------- + +.. py:function:: paddle.fluid.nets.simple_img_conv_pool(input, num_filters, filter_size, pool_size, pool_stride, pool_padding=0, pool_type='max', global_pooling=False, conv_stride=1, conv_padding=0, conv_dilation=1, conv_groups=1, param_attr=None, bias_attr=None, act=None, use_cudnn=True) + + ``simple_img_conv_pool`` 由一个Convolution2d和一个Pool2d组成。 + +参数: + - **input** (Variable) - 输入图像的格式为[N,C,H,W]。 + - **num_filters** (int) - ``filter`` 的数量。它与输出的通道相同。 + - **filter_size** (int | list | tuple) - 过滤器大小。如果 ``filter_size`` 是列表或元组,则它必须包含两个整数(filter_size_H,filter_size_W)。否则,filter_size_H = filter_size_W = filter_size。 + - **pool_size** (int | list | tuple) - Pool2d池化层大小。如果pool_size是列表或元组,则它必须包含两个整数(pool_size_H,pool_size_W)。否则,pool_size_H = pool_size_W = pool_size。 + - **pool_stride** (int | list | tuple) - Pool2d池化层步长。如果pool_stride是列表或元组,则它必须包含两个整数(pooling_stride_H,pooling_stride_W)。否则,pooling_stride_H = pooling_stride_W = pool_stride。 + - **pool_padding** (int | list | tuple) - Pool2d池化层的padding。如果pool_padding是列表或元组,则它必须包含两个整数(pool_padding_H,pool_padding_W)。否则,pool_padding_H = pool_padding_W = pool_padding。默认值为0。 + - **pool_type** (str) - 池化类型可以是 ``max-pooling`` 的 ``max`` 和平均池的 ``avg`` 。默认 ``max`` 。 + - **global_pooling** (bool)- 是否使用全局池。如果global_pooling = true,则忽略pool_size和pool_padding。默认为False + - **conv_stride** (int | list | tuple) - conv2d Layer的步长。如果stride是列表或元组,则它必须包含两个整数,(conv_stride_H,conv_stride_W)。否则,conv_stride_H = conv_stride_W = conv_stride。默认值:conv_stride = 1。 + - **conv_padding** (int | list | tuple) - conv2d Layer的padding大小。如果padding是列表或元组,则它必须包含两个整数(conv_padding_H,conv_padding_W)。否则,conv_padding_H = conv_padding_W = conv_padding。默认值:conv_padding = 0。 + - **conv_dilation** (int | list | tuple) - conv2d Layer的dilation大小。如果dilation是列表或元组,则它必须包含两个整数(conv_dilation_H,conv_dilation_W)。否则,conv_dilation_H = conv_dilation_W = conv_dilation。默认值:conv_dilation = 1。 + - **conv_groups** (int) - conv2d Layer的组数。根据Alex Krizhevsky的Deep CNN论文中的分组卷积:当group = 2时,前半部分滤波器仅连接到输入通道的前半部分,而后半部分滤波器仅连接到后半部分输入通道。默认值:groups = 1。 + - **param_attr** (ParamAttr | None) - 可学习参数的参数属性或conv2d权重。如果将其设置为None或ParamAttr的一个属性,则conv2d将创建ParamAttr作为param_attr。如果未设置param_attr的初始化,则使用 :math:`Normal(0.0,std)` 初始化参数,并且 ``std`` 为 :math:`(\frac{2.0 }{filter\_elem\_num})^{0.5}` 。默认值:None + - **bias_attr** (ParamAttr | bool | None) - conv2d的bias参数属性。如果设置为False,则不会向输出单元添加bias。如果将其设置为None或ParamAttr的一个属性,则conv2d将创建ParamAttr作为bias_attr。如果未设置bias_attr的初始化程序,则将偏差初始化为零。默认值:None + - **act** (str) - conv2d的激活类型,如果设置为None,则不附加激活。默认值:无。 + - **use_cudnn** (bool) - 是否使用cudnn内核,仅在安装cudnn库时才有效。默认值:True。 + +返回: Convolution2d和Pool2d之后输入的结果。 + +返回类型: 变量(Variable) + +**示例代码** + +.. code-block:: python + + img = fluid.layers.data(name='img', shape=[1, 28, 28], dtype='float32') + conv_pool = fluid.nets.simple_img_conv_pool(input=img, + filter_size=5, + num_filters=20, + pool_size=2, + pool_stride=2, + act="relu") + + + + + + + + + + + diff --git a/doc/fluid/api_cn/optimizer_cn.rst b/doc/fluid/api_cn/optimizer_cn.rst index 4d900d82536d81af7d2fe3663c5bc87f8903f20a..a5ac3ac2302c6c805bddde1aabfa0b7f42956eb6 100644 --- a/doc/fluid/api_cn/optimizer_cn.rst +++ b/doc/fluid/api_cn/optimizer_cn.rst @@ -1,14 +1,37 @@ - ################# fluid.optimizer ################# +.. _cn_api_fluid_optimizer_Adadelta: + +Adadelta +------------------------------- + +.. py:attribute:: paddle.fluid.optimizer.Adadelta + +``AdadeltaOptimizer`` 的别名 + + + + + + +.. _cn_api_fluid_optimizer_Adagrad: + +Adagrad +------------------------------- + +.. py:attribute:: paddle.fluid.optimizer.Adagrad + +``AdagradOptimizer`` 的别名 + + .. _cn_api_fluid_optimizer_AdagradOptimizer: AdagradOptimizer ->>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.optimizer.AdagradOptimizer(learning_rate, epsilon=1e-06, regularization=None, name=None) @@ -37,45 +60,42 @@ http://cs231n.github.io/neural-networks-3/#ada 用于维持数值稳定性,避 optimizer = fluid.optimizer.Adagrad(learning_rate=0.2) optimizer.minimize(cost) -AdamOptimizer ->>>>>>>>>>>>> -.. py:class:: paddle.fluid.optimizer. AdamOptimizer(learning_rate=0.001, beta1=0.9, beta2=0.999, epsilon=1e-08, regularization=None, name=None) -该函数实现了自适应矩估计优化器,介绍自Adam论文:https://arxiv.org/abs/1412.6980的第二节。Adam是一阶基于梯度下降的算法,基于自适应低阶矩估计。 -Adam更新如下: -.. math:: - t & = t + 1\\moment\_out & = {\beta}_1 * moment + (1 - {\beta}_1) * grad\\inf\_norm\_out & = max({\beta}_2 * inf\_norm + \epsilon, |grad|)\\learning\_rate & = \frac{learning\_rate}{1 - {\beta}_1^t}\\param\_out & = param - learning\_rate * \frac{moment\_out}{inf\_norm\_out} -参数: - - **learning_rate** (float|Variable)-学习率,用于更新参数。作为数据参数,可以是一个浮点类型值或有一个浮点类型值的变量 - - **beta1** (float)-一阶矩估计的指数衰减率 - - **beta2** (float)-二阶矩估计的指数衰减率 - - **epsilon** (float)-保持数值稳定性的短浮点类型值 - - **regularization** - 规则化函数,例如''fluid.regularizer.L2DecayRegularizer - - **name** - 可选名称前缀 +.. _cn_api_fluid_optimizer_Adam: -**代码示例**: +Adam +------------------------------- + +.. py:attribute:: paddle.fluid.optimizer.Adam + +``AdamOptimizer`` 的别名 -.. code-block:: python: - optimizer = fluid.optimizer.Adam(learning_rate=0.2) - optimizer.minimize(cost) -.. note:: - 目前,AdamaxOptimizer不支持稀疏参数优化 + +.. _cn_api_fluid_optimizer_Adamax: + +Adamax +------------------------------- + +.. py:attribute:: paddle.fluid.optimizer.Adamax + +``AdamaxOptimizer`` 的别名 + + -英文版API文档: :ref:`api_fluid_optimizer_AdagradOptimizer` .. _cn_api_fluid_optimizer_AdamaxOptimizer: AdamaxOptimizer ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.optimizer.AdamaxOptimizer(learning_rate=0.001, beta1=0.9, beta2=0.999, epsilon=1e-08, regularization=None, name=None) @@ -119,12 +139,68 @@ Adamax 更新规则: -英文版API文档: :ref:`api_fluid_optimizer_AdamaxOptimizer` + + + + + + + + +.. _cn_api_fluid_optimizer_AdamOptimizer: + +AdamOptimizer +------------------------------- + +.. py:class:: paddle.fluid.optimizer. AdamOptimizer(learning_rate=0.001, beta1=0.9, beta2=0.999, epsilon=1e-08, regularization=None, name=None) + +该函数实现了自适应矩估计优化器,介绍自 `Adam论文 `_ 的第二节。Adam是一阶基于梯度下降的算法,基于自适应低阶矩估计。 +Adam更新如下: + +.. math:: + + t & = t + 1\\moment\_out & = {\beta}_1 * moment + (1 - {\beta}_1) * grad\\inf\_norm\_out & = max({\beta}_2 * inf\_norm + \epsilon, |grad|)\\learning\_rate & = \frac{learning\_rate}{1 - {\beta}_1^t}\\param\_out & = param - learning\_rate * \frac{moment\_out}{inf\_norm\_out} + +参数: + - **learning_rate** (float|Variable)-学习率,用于更新参数。作为数据参数,可以是一个浮点类型值或有一个浮点类型值的变量 + - **beta1** (float)-一阶矩估计的指数衰减率 + - **beta2** (float)-二阶矩估计的指数衰减率 + - **epsilon** (float)-保持数值稳定性的短浮点类型值 + - **regularization** - 规则化函数,例如''fluid.regularizer.L2DecayRegularizer + - **name** - 可选名称前缀 + +**代码示例**: + +.. code-block:: python: + + optimizer = fluid.optimizer.Adam(learning_rate=0.2) + optimizer.minimize(cost) + + + + + + + + + +.. _cn_api_fluid_optimizer_DecayedAdagrad: + +DecayedAdagrad +------------------------------- + +.. py:attribute:: paddle.fluid.optimizer.DecayedAdagrad + +``DecayedAdagradOptimizer`` 的别名 + + + + .. _cn_api_fluid_optimizer_DecayedAdagradOptimizer: DecayedAdagradOptimizer ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.optimizer.DecayedAdagradOptimizer(learning_rate, decay=0.95, epsilon=1e-06, regularization=None, name=None) @@ -160,12 +236,27 @@ Decayed Adagrad Optimizer -英文版API文档: :ref:`api_fluid_optimizer_DecayedAdagradOptimizer` + + + + + +.. _cn_api_fluid_optimizer_Ftrl: + +Ftrl +------------------------------- + +.. py:attribute:: paddle.fluid.optimizer.Ftrl + +``FtrlOptimizer`` 的别名 + + + .. _cn_api_fluid_optimizer_FtrlOptimizer: FtrlOptimizer ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.optimizer.FtrlOptimizer(learning_rate, l1=0.0, l2=0.0, lr_power=-0.5,regularization=None, name=None) @@ -194,9 +285,9 @@ TFRTL 原始论文: ( `https://www.eecs.tufts.edu/~dsculley/papers/ad-click-pred 参数: - **learning_rate** (float|Variable)-全局学习率。 - - **l1** (float) - - **l2** (float) - - **lr_power** (float) + - **l1** (float) - 暂无,请等待后期更新 + - **l2** (float) - 暂无,请等待后期更新 + - **lr_power** (float) - 暂无,请等待后期更新 - **regularization** - 正则化器,例如 ``fluid.regularizer.L2DecayRegularizer`` - **name** — 可选的名称前缀 @@ -211,29 +302,32 @@ TFRTL 原始论文: ( `https://www.eecs.tufts.edu/~dsculley/papers/ad-click-pred _, params_grads = optimizer.minimize(cost) .. note:: -目前, FtrlOptimizer 不支持 sparse gradient + 目前, FtrlOptimizer 不支持 sparse gradient + + + -英文版API文档: :ref:`api_fluid_optimizer_FtrlOptimizer` .. _cn_api_fluid_optimizer_LarsMomentum: LarsMomentum ->>>>>>>>>>>>>> +------------------------------- -:code:`fluid.optimizer.LarsMomentumOptimizer` 的别名 +.. py:attribute:: paddle.fluid.optimizer.LarsMomentum + +``fluid.optimizer.LarsMomentumOptimizer`` 的别名 -英文版API文档: :ref:`api_fluid_optimizer_LarsMomentum` .. _cn_api_fluid_optimizer_LarsMomentumOptimizer: LarsMomentumOptimizer ->>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.optimizer.LarsMomentumOptimizer(learning_rate, momentum, lars_coeff=0.001, lars_weight_decay=0.0005, regularization=None, name=None) @@ -265,12 +359,14 @@ LARS支持的Momentum优化器 -英文版API文档: :ref:`api_fluid_optimizer_LarsMomentumOptimizer` + + + .. _cn_api_fluid_optimizer_ModelAverage: ModelAverage ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.optimizer.ModelAverage(average_window_rate, min_average_window=10000, max_average_window=10000, regularization=None, name=None) @@ -315,12 +411,25 @@ ModelAverage -英文版API文档: :ref:`api_fluid_optimizer_ModelAverage` + + + + +.. _cn_api_fluid_optimizer_Momentum: + +Momentum +------------------------------- + +.. py:attribute:: paddle.fluid.optimizer.Momentum + +``MomentumOptimizer`` 的别名 + + .. _cn_api_fluid_optimizer_MomentumOptimizer: MomentumOptimizer ->>>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.optimizer.MomentumOptimizer(learning_rate, momentum, use_nesterov=False, regularization=None, name=None) @@ -349,12 +458,14 @@ MomentumOptimizer -英文版API文档: :ref:`api_fluid_optimizer_MomentumOptimizer` + + + .. _cn_api_fluid_optimizer_RMSPropOptimizer: RMSPropOptimizer ->>>>>>>>>>>>>>>>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.optimizer.RMSPropOptimizer(learning_rate, rho=0.95, epsilon=1e-06, momentum=0.0, centered=False, regularization=None, name=None) @@ -406,12 +517,27 @@ RMSPropOptimizer -英文版API文档: :ref:`api_fluid_optimizer_RMSPropOptimizer` + + + +.. _cn_api_fluid_optimizer_SGD: + +SGD +------------------------------- + +.. py:attribute:: paddle.fluid.optimizer.SGD + +``SGDOptimizer`` 的别名 + + + + + .. _cn_api_fluid_optimizer_SGDOptimizer: SGDOptimizer ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.optimizer.SGDOptimizer(learning_rate, regularization=None, name=None) @@ -438,5 +564,7 @@ SGDOptimizer -英文版API文档: :ref:`api_fluid_optimizer_SGDOptimizer` + + + diff --git a/doc/fluid/api_cn/param_attr_cn.rst b/doc/fluid/api_cn/param_attr_cn.rst index 5d1e151f0ad6e1aaec11b9d8bbe1587db2203804..1e32d1f8a9eadbd29baad35be9219abd3203bfe7 100644 --- a/doc/fluid/api_cn/param_attr_cn.rst +++ b/doc/fluid/api_cn/param_attr_cn.rst @@ -1,14 +1,53 @@ - ################# fluid.param_attr ################# + +.. _cn_api_fluid_param_attr_ParamAttr: + + +ParamAttr +------------------------------- + + +.. py:class:: paddle.fluid.param_attr.ParamAttr(name=None, initializer=None, learning_rate=1.0, regularizer=None, trainable=True, gradient_clip=None, do_model_average=False) + +该类代表了参数的各种属性。 为了使神经网络训练过程更加流畅,用户可以根据需要调整参数属性。比如learning rate(学习率), regularization(正则化), trainable(可训练性), do_model_average(平均化模型)和参数初始化方法. + +参数: + - **name** (str) – 参数名。默认为None。 + - **initializer** (Initializer) – 初始化该参数的方法。 默认为None + - **learning_rate** (float) – 参数的学习率。计算方法为 global_lr*parameter_lr∗scheduler_factor。 默认为1.0 + - **regularizer** (WeightDecayRegularizer) – 正则因子. 默认为None + - **trainable** (bool) – 该参数是否可训练。默认为True + - **gradient_clip** (BaseGradientClipAttr) – 减少参数梯度的方法。默认为None + - **do_model_average** (bool) – 该参数是否服从模型平均值。默认为False + +**代码示例** + +.. code-block:: python + + w_param_attrs = fluid.ParamAttr(name="fc_weight", + learning_rate=0.5, + regularizer=fluid.L2Decay(1.0), + trainable=True) + y_predict = fluid.layers.fc(input=x, size=10, param_attr=w_param_attrs) + + + + + + + + + + .. _cn_api_fluid_param_attr_WeightNormParamAttr: WeightNormParamAttr ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.param_attr.WeightNormParamAttr(dim=None, name=None, initializer=None, learning_rate=1.0, regularizer=None, trainable=True, gradient_clip=None, do_model_average=False) @@ -41,39 +80,11 @@ WeightNormParamAttr -英文版API文档: :ref:`api_fluid_param_attr_WeightNormParamAttr` - -.. _cn_api_fluid_ParamAttr: - -ParamAttr ->>>>>>>>>>>>>>>>>>>>>>>>> -.. py:class:: paddle.fluid.param_attr.ParamAttr(name=None, initializer=None, learning_rate=1.0, regularizer=None, trainable=True, gradient_clip=None, do_model_average=False) - -该类代表了参数的各种属性。 为了使神经网络训练过程更加流畅,用户可以根据需要调整参数属性。比如learning rate(学习率), regularization(正则化), trainable(可训练性), do_model_average(平均化模型)和参数初始化方法. -参数: - - **name** (str) – 参数名。默认为None。 - - **initializer** (Initializer) – 初始化该参数的方法。 默认为None - - **learning_rate** (float) – 参数的学习率。计算方法为 global_lr*parameter_lr∗scheduler_factor。 默认为1.0 - - **regularizer** (WeightDecayRegularizer) – 正则因子. 默认为None - - **trainable** (bool) – 该参数是否可训练。默认为True - - **gradient_clip** (BaseGradientClipAttr) – 减少参数梯度的方法。默认为None - - **do_model_average** (bool) – 该参数是否服从模型平均值。默认为False - -**代码示例** - -.. code-block:: python - - w_param_attrs = fluid.ParamAttr(name="fc_weight", - learning_rate=0.5, - regularizer=fluid.L2Decay(1.0), - trainable=True) - y_predict = fluid.layers.fc(input=x, size=10, param_attr=w_param_attrs) -英文版API文档: :ref:`api_fluid_ParamAttr` diff --git a/doc/fluid/api_cn/profiler_cn.rst b/doc/fluid/api_cn/profiler_cn.rst index a88d5119bbb829af1657b544f252c458062f6a90..52442b2da2662df462ccb6a3b0484ff02e72a40c 100644 --- a/doc/fluid/api_cn/profiler_cn.rst +++ b/doc/fluid/api_cn/profiler_cn.rst @@ -1,4 +1,3 @@ - ################# fluid.profiler ################# @@ -8,7 +7,7 @@ .. _cn_api_fluid_profiler_cuda_profiler: cuda_profiler ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.profiler.cuda_profiler(*args, **kwds) @@ -19,10 +18,10 @@ CUDA分析器。通过CUDA运行时应用程序编程接口对CUDA程序进行 参数: - **output_file** (string) – 输出文件名称, 输出结果将会写入该文件 - **output_mode** (string) – 输出格式是有 key-value 键值对 和 逗号的分割的格式。格式应该是' kvp '或' csv ' - - **config** (list of string) – 参考“Compute Command Line Profiler User Guide” 查阅 profiler options 和 counter相关信息 + - **config** (list of string) – 参考"Compute Command Line Profiler User Guide" 查阅 profiler options 和 counter相关信息 抛出异常: - - ``ValueError`` - 如果 ``output_mode`` 不在 [‘kvp’, ‘csv’] 中 + - ``ValueError`` - 如果 ``output_mode`` 不在 ['kvp', 'csv'] 中 **代码示例** @@ -54,12 +53,14 @@ CUDA分析器。通过CUDA运行时应用程序编程接口对CUDA程序进行 -英文版API文档: :ref:`api_fluid_profiler_cuda_profiler` + + + .. _cn_api_fluid_profiler_profiler: profiler ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.profiler.profiler(*args, **kwds) @@ -69,12 +70,12 @@ profile interface 。与cuda_profiler不同,此profiler可用于分析CPU和GP 如果 state== ' All ',在profile_path 中写入文件 profile proto 。该文件记录执行期间的时间顺序信息。然后用户可以看到这个文件的时间轴,请参考 `https://github.com/PaddlePaddle/Paddle/blob/develop/doc/fluid/howto/optimization/timeline.md `_ 参数: - - **state** (string) – profiling state, 取值为 ‘CPU’ 或 ‘GPU’, profiler 使用 CPU timer 或GPU timer 进行 profiling. 虽然用户可能在开始时指定了执行位置(CPUPlace/CUDAPlace),但是为了灵活性,profiler不会使用这个位置。 - - **sorted_key** (string) – 如果为None,prfile的结果将按照事件的第一次结束时间顺序打印。否则,结果将按标志排序。标志取值为“call”、“total”、“max”、“min” “ave”之一,根据调用着的数量进行排序。total表示按总执行时间排序,max 表示按最大执行时间排序。min 表示按最小执行时间排序。ave表示按平均执行时间排序。 - - **profile_path** (string) – 如果 state == ‘All’, 结果将写入文件 profile proto. + - **state** (string) – profiling state, 取值为 'CPU' 或 'GPU', profiler 使用 CPU timer 或GPU timer 进行 profiling. 虽然用户可能在开始时指定了执行位置(CPUPlace/CUDAPlace),但是为了灵活性,profiler不会使用这个位置。 + - **sorted_key** (string) – 如果为None,prfile的结果将按照事件的第一次结束时间顺序打印。否则,结果将按标志排序。标志取值为"call"、"total"、"max"、"min" "ave"之一,根据调用着的数量进行排序。total表示按总执行时间排序,max 表示按最大执行时间排序。min 表示按最小执行时间排序。ave表示按平均执行时间排序。 + - **profile_path** (string) – 如果 state == 'All', 结果将写入文件 profile proto. 抛出异常: - - ``ValueError`` – 如果state 取值不在 [‘CPU’, ‘GPU’, ‘All’]中. 如果 sorted_key 取值不在 [‘calls’, ‘total’, ‘max’, ‘min’, ‘ave’] + - ``ValueError`` – 如果state 取值不在 ['CPU', 'GPU', 'All']中. 如果 sorted_key 取值不在 ['calls', 'total', 'max', 'min', 'ave'] **代码示例** @@ -93,12 +94,14 @@ profile interface 。与cuda_profiler不同,此profiler可用于分析CPU和GP -英文版API文档: :ref:`api_fluid_profiler_profiler` + + + .. _cn_api_fluid_profiler_reset_profiler: reset_profiler ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.profiler.reset_profiler() @@ -118,12 +121,14 @@ reset_profiler -英文版API文档: :ref:`api_fluid_profiler_reset_profiler` + + + .. _cn_api_fluid_profiler_start_profiler: start_profiler ->>>>>>>>>>>> +------------------------------- .. py:function:: paddle.fluid.profiler.start_profiler(state) @@ -134,10 +139,10 @@ start_profiler 如果 state== ' All ',在profile_path 中写入文件 profile proto 。该文件记录执行期间的时间顺序信息。然后用户可以看到这个文件的时间轴,请参考 `https://github.com/PaddlePaddle/Paddle/blob/develop/doc/fluid/howto/optimization/timeline.md `_ 参数: - - **state** (string) – profiling state, 取值为 ‘CPU’ 或 ‘GPU’ 或 ‘All’, ‘CPU’ 代表只分析 cpu. ‘GPU’ 代表只分析 GPU . ‘All’ 会产生 timeline. + - **state** (string) – profiling state, 取值为 'CPU' 或 'GPU' 或 'All', 'CPU' 代表只分析 cpu. 'GPU' 代表只分析 GPU . 'All' 会产生 timeline. 抛出异常: - - ``ValueError`` – 如果state 取值不在 [‘CPU’, ‘GPU’, ‘All’]中 + - ``ValueError`` – 如果state 取值不在 ['CPU', 'GPU', 'All']中 **代码示例** @@ -157,12 +162,14 @@ start_profiler -英文版API文档: :ref:`api_fluid_profiler_start_profiler` + + + .. _cn_api_fluid_profiler_stop_profiler: stop_profiler ->>>>>>>>>>>> +------------------------------- .. py:function::paddle.fluid.profiler.stop_profiler(sorted_key=None, profile_path='/tmp/profile') @@ -170,12 +177,12 @@ stop_profiler 不能使用 fluid.profiler.profiler`` 参数: - - **sorted_key** (string) – 如果为None,prfile的结果将按照事件的第一次结束时间顺序打印。否则,结果将按标志排序。标志取值为“call”、“total”、“max”、“min” “ave”之一,根据调用着的数量进行排序。total表示按总执行时间排序,max 表示按最大执行时间排序。min 表示按最小执行时间排序。ave表示按平均执行时间排序。 - - **profile_path** (string) - 如果 state == ‘All’, 结果将写入文件 profile proto. + - **sorted_key** (string) – 如果为None,prfile的结果将按照事件的第一次结束时间顺序打印。否则,结果将按标志排序。标志取值为"call"、"total"、"max"、"min" "ave"之一,根据调用着的数量进行排序。total表示按总执行时间排序,max 表示按最大执行时间排序。min 表示按最小执行时间排序。ave表示按平均执行时间排序。 + - **profile_path** (string) - 如果 state == 'All', 结果将写入文件 profile proto. 抛出异常: - - ``ValueError`` – 如果state 取值不在 [‘CPU’, ‘GPU’, ‘All’]中 + - ``ValueError`` – 如果state 取值不在 ['CPU', 'GPU', 'All']中 **代码示例** @@ -192,5 +199,7 @@ stop_profiler -英文版API文档: :ref:`api_fluid_profiler_stop_profiler` + + + diff --git a/doc/fluid/api_cn/recordio_writer_cn.rst b/doc/fluid/api_cn/recordio_writer_cn.rst new file mode 100644 index 0000000000000000000000000000000000000000..3a6769616913cc374bece90fce2f07704df52ad4 --- /dev/null +++ b/doc/fluid/api_cn/recordio_writer_cn.rst @@ -0,0 +1,77 @@ +####################### + fluid.recordio_writer +####################### + + + + +.. _cn_api_fluid_recordio_writer_convert_reader_to_recordio_file: + +convert_reader_to_recordio_file +------------------------------- + +.. py:function:: paddle.fluid.recordio_writer.convert_reader_to_recordio_file(filename, reader_creator, feeder, compressor=Compressor.Snappy, max_num_records=1000, feed_order=None) + +将 Python reader 转换为recordio文件 + +**代码示例:** + +.. code-block:: python + + import paddle.fluid as fluid + import paddle.dataset.mnist as mnist + import paddle + + tmp_program = fluid.Program() + with fluid.program_guard(tmp_program): + img = fluid.layers.data(name='img', shape=[784]) + label = fluid.layers.data(name='label', shape=[1], dtype='int64') + feeder = fluid.DataFeeder(feed_list=[img, label], place=fluid.CPUPlace()) + # mnist.recordio 会在当前目录生成 + fluid.recordio_writer.convert_reader_to_recordio_file( + filename="mnist.recordio", + reader_creator=paddle.batch(mnist.train(), batch_size=32), + feeder=feeder) + +参数: + - **filename** (str) - recordio文件名 + - **reader_creator** (callable) - Python reader的创造器。可参考 :ref:`api_guide_python_reader` + - **feeder** (DataFeeder) - 数据处理实例。用于将 :code:`reader_creator` 转换为 :code:`lod_tensor` + - **compressor** – 必须在 :code:`fluid.core.RecordIOWriter.Compressor.Snappy` 或 :code:` fluid.core.RecordIOWriter.Compressor.NoCompress` 中, 默认情况下使用 :code:`Snappy` + - **max_num_records** (int) – 一个 chuck 中 records 的最大数量。每个 records 都是 reader 函数的返回值 + - **feed_order** (list) - reader 返回的变量名的顺序 + +返回: 保存的 record 的数目 + +返回类型: int + + + + + + + + + +.. _cn_api_fluid_recordio_writer_convert_reader_to_recordio_files: + +convert_reader_to_recordio_files +------------------------------- + +.. py:function:: paddle.fluid.recordio_writer.convert_reader_to_recordio_files(filename, batch_per_file, reader_creator, feeder, compressor=Compressor.Snappy, max_num_records=1000, feed_order=None) + +该函数可以将一个python驱动的reader(数据读取器)转变为多个recodio文件。 + +该API实现的功能和 ``convert_reader_to_recordio_file`` 基本相同,只不过本函数会生成多个recordio文件。 +每个文件最多存储 ``batch_per_file`` 条记录。 + +请参照 :ref:`cn_api_fluid_recordio_writer_convert_reader_to_recordio_file` 获取更详细的介绍。 + + + + + + + + + diff --git a/doc/fluid/api_cn/regularizer_cn.rst b/doc/fluid/api_cn/regularizer_cn.rst index f1db193e193923b21a9b0fcb451bccb3b1bd39be..19c33bd8541e75007fa840aae4e80bb46667e016 100644 --- a/doc/fluid/api_cn/regularizer_cn.rst +++ b/doc/fluid/api_cn/regularizer_cn.rst @@ -1,14 +1,22 @@ - -################# +################### fluid.regularizer -################# +################### + +.. _cn_api_fluid_regularizer_L1Decay: + +L1Decay +------------------------------- + +.. py:attribute:: paddle.fluid.regularizer.L1Decay + +``L1DecayRegularizer`` 的别名 .. _cn_api_fluid_regularizer_L1DecayRegularizer: L1DecayRegularizer ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.regularizer.L1DecayRegularizer(regularization_coeff=0.0) @@ -37,12 +45,26 @@ L1正则将会稀疏化权重矩阵。 -英文版API文档: :ref:`api_fluid_regularizer_L1DecayRegularizer` + + + +.. _cn_api_fluid_regularizer_L2Decay: + +L2Decay +------------------------------- + +.. py:attribute:: paddle.fluid.regularizer.L2Decay + +``L2DecayRegularizer`` 的别名 + + + + .. _cn_api_fluid_regularizer_L2DecayRegularizer: L2DecayRegularizer ->>>>>>>>>>>> +------------------------------- .. py:class:: paddle.fluid.regularizer.L2DecayRegularizer(regularization_coeff=0.0) @@ -68,5 +90,7 @@ L2DecayRegularizer -英文版API文档: :ref:`api_fluid_regularizer_L2DecayRegularizer` + + + diff --git a/doc/fluid/api_cn/transpliter_cn.rst b/doc/fluid/api_cn/transpiler_cn.rst similarity index 88% rename from doc/fluid/api_cn/transpliter_cn.rst rename to doc/fluid/api_cn/transpiler_cn.rst index 4c1d5b810c7ef7b9e68291500800c4891fd35464..1e48c4f6036807ac90e9892aa118ad92a00acf21 100644 --- a/doc/fluid/api_cn/transpliter_cn.rst +++ b/doc/fluid/api_cn/transpiler_cn.rst @@ -1,244 +1,259 @@ - -################# - fluid.transpiler -################# - - - - - - -.. _cn_api_fluid_DistributeTranspiler: - -DistributeTranspiler ->>>>>>>>>>>>>>>>>>>>>>>>>>>>>> - -.. py:class:: paddle.fluid.transpiler.DistributeTranspiler (config=None) - - -该类可以把fluid program转变为分布式数据并行计算程序(distributed data-parallelism programs),可以有Pserver和NCCL2两种模式。 -当program在Pserver(全称:parameter server)模式下, ``main_program`` (主程序)转为使用一架远程parameter server(即pserver,参数服务器)来进行参数优化,并且优化图会被输入到一个pserver program中。 -在NCCL2模式下,transpiler会在 ``startup_program`` 中附加一个 ``NCCL_ID`` 广播算子(broadcasting operators)来实现在该集群中所有工作结点共享``NCCL_ID`` 。 -调用 ``transpile_nccl2`` 后, 你 **必须** 将 ``trainer_id`` , ``num_trainers`` 参数提供给 ``ParallelExecutor`` 来启动NCCL2分布式模式。 - - - - -**代码示例** - -.. code-block:: python - - # for pserver mode - pserver_endpoints = "192.168.0.1:6174,192.168.0.2:6174" - trainer_endpoints = "192.168.0.1:6174,192.168.0.2:6174" - current_endpoint = "192.168.0.1:6174" - trainer_id = 0 - trainers = 4 - role = os.getenv("PADDLE_TRAINING_ROLE") - - t = fluid.DistributeTranspiler() - t.transpile( - trainer_id, pservers=pserver_endpoints, trainers=trainers) - if role == "PSERVER": - pserver_program = t.get_pserver_program(current_endpoint) - pserver_startup_program = t.get_startup_program(current_endpoint, - pserver_program) - elif role == "TRAINER": - trainer_program = t.get_trainer_program() - - # for nccl2 mode - config = fluid.DistributeTranspilerConfig() - config.mode = "nccl2" - t = fluid.DistributeTranspiler(config=config) - t.transpile(trainer_id, workers=workers, current_endpoint=curr_ep) - exe = fluid.ParallelExecutor( - use_cuda, - loss_name=loss_var.name, - num_trainers=len(trainers.split(",)), - trainer_id=trainer_id - ) - - - -.. py:method:: transpile(trainer_id, program=None, pservers='127.0.0.1:6174', trainers=1, sync_mode=True, startup_program=None, current_endpoint='127.0.0.1:6174') - -该方法可以运行该transpiler(转译器)。 - -参数: - - **trainer_id** (int) – 当前Trainer worker的id, 如果有n个Trainer worker, id 取值范围为0 ~ n-1 - - **program** (Program|None) – 待transpile(转译)的program, 缺省为 ``fluid.default_main_program()`` - - **pservers** (str) – 内容为Pserver列表的字符串,格式为:按逗号区分不同的Pserver,每个Pserver的格式为 *ip地址:端口号* - - **trainers** (int|str) – 在Pserver模式下,该参数指Trainer机的个数;在nccl2模式下,它是一个内容为Trainer终端列表的字符串 - - **sync_mode** (bool) – 是否做同步训练(synchronous training), 默认为True - - **startup_program** (Program|None) – 待transpile(转译)的startup_program,默认为 ``fluid.default_main_program()`` - - **current_endpoint** (str) – 当需要把program转译(transpile)至NCCL2模式下时,需要将当前endpoint(终端)传入该参数。Pserver模式不使用该参数 - -.. py:method:: get_trainer_program(wait_port=True) - - -该方法可以得到Trainer侧的program。 - -返回: Trainer侧的program - -返回类型: Program - - - -.. py:method:: get_pserver_program(endpoint) - - -该方法可以得到Pserver(参数服务器)侧的程序 - -参数: - - **endpoint** (str) – 当前Pserver终端 - -返回: 当前Pserver需要执行的program - -返回类型: Program - - -.. py:method:: get_pserver_programs(endpoint) - - -该方法可以得到Pserver侧用于分布式训练的 ``main_program`` 和 ``startup_program`` 。 - -参数: - - **endpoint** (str) – 当前Pserver终端 - -返回: (main_program, startup_program), “Program”类型的元组 - -返回类型: tuple - - -.. py:method:: get_startup_program(endpoint, pserver_program=None, startup_program=None) - - -**该函数已停止使用** -获取当前Pserver的startup_program,如果有多个被分散到不同blocks的变量,则修改operator的输入变量。 - -参数: - - **endpoint** (str) – 当前Pserver终端 - - **pserver_program** (Program) – 已停止使用。 先调用get_pserver_program - - **startup_program** (Program) – 已停止使用。应在初始化时传入startup_program - -返回: Pserver侧的startup_program - -返回类型: Program - - - -英文版API文档: :ref:`api_fluid_DistributeTranspiler` - -.. _cn_api_fluid_transpiler_DistributeTranspilerConfig: - -DistributeTranspilerConfig ->>>>>>>>>>>> - -.. py:class:: paddle.fluid.transpiler.DistributeTranspilerConfig - -.. py:method:: slice_var_up (bool) - -为Pserver将张量切片, 默认为True - -.. py:method:: split_method (PSDispatcher) - -可使用 RoundRobin 或者 HashName - -注意: 尝试选择最佳方法来达到负载均衡。 - - -.. py:attribute:: min_block_size (int) - -最小数据块的大小 - -注意: 根据:https://github.com/PaddlePaddle/Paddle/issues/8638#issuecomment-369912156, 当数据块大小超过2MB时,我们可以有效地使用带宽。如果你想更改它,请详细查看slice_variable函数。 - - - -英文版API文档: :ref:`api_fluid_transpiler_DistributeTranspilerConfig` - -.. _cn_api_fluid_transpiler_HashName: - -HashName ->>>>>>>>>>>> - -.. py:class:: paddle.fluid.transpiler.HashName(pserver_endpoints) - -使用 python ``Hash()`` 函数将变量名散列到多个pserver终端。 - -参数: - - **pserver_endpoints** (list) - endpoint (ip:port)的 list - - - - -英文版API文档: :ref:`api_fluid_transpiler_HashName` - -.. _cn_api_fluid_transpiler_memory_optimize: - -memory_optimize ->>>>>>>>>>>> - -.. py:function:: paddle.fluid.transpiler.memory_optimize(input_program, skip_opt_set=None, print_log=False, level=0, skip_grads=False) - -通过重用var内存来优化内存。 - -注意:它不支持block中嵌套子block。 - -参数: - - **input_program** (str) – 输入Program。 - - **skip_opt_set** (set) – set中的vars将不被内存优化。 - - **print_log** (bool) – 是否打印debug日志。 - - **level** (int) - 如果 level=0 并且shape是完全相等,则重用。 - -返回: None - -英文版API文档: :ref:`api_fluid_transpiler_memory_optimize` - - - - -.. _cn_api_fluid_transpiler_release_memory: - -release_memory ->>>>>>>>>>>>>>>>>>>>>>>>>>> - -.. py:function:: paddle.fluid.transpiler.release_memory(input_program, skip_opt_set=None) - - -该函数可以调整输入program,插入 ``delete_op`` 删除算子,提前删除不需要的变量。 -改动是在变量本身上进行的。 - -.. note:: - 该API还在试验阶段,会在后期版本中删除。不建议用户使用。 - -参数: - - **input_program** (Program) – 在此program中插入 ``delete_op`` - - **skip_opt_set** (set) – 在内存优化时跳过的变量的集合 - -返回: None - -英文版API文档: :ref:`api_fluid_transpiler_release_memory` - - - - -.. _cn_api_fluid_transpiler_RoundRobin: - -RoundRobin ->>>>>>>>>>>> - -.. py:class:: paddle.fluid.transpiler.RoundRobin(pserver_endpoints) - -使用 ``RondRobin`` 方法将变量分配给服务器端点。 - -`RondRobin `_ - -参数: - - **pserver_endpoints** (list) - endpoint (ip:port)的 list - - - - -英文版API文档: :ref:`api_fluid_transpiler_RoundRobin` - +################# + fluid.transpiler +################# + + + +.. _cn_api_fluid_transpiler_DistributeTranspiler: + +DistributeTranspiler +------------------------------- + +.. py:class:: paddle.fluid.transpiler.DistributeTranspiler (config=None) + + +该类可以把fluid program转变为分布式数据并行计算程序(distributed data-parallelism programs),可以有Pserver和NCCL2两种模式。 +当program在Pserver(全称:parameter server)模式下, ``main_program`` (主程序)转为使用一架远程parameter server(即pserver,参数服务器)来进行参数优化,并且优化图会被输入到一个pserver program中。 +在NCCL2模式下,transpiler会在 ``startup_program`` 中附加一个 ``NCCL_ID`` 广播算子(broadcasting operators)来实现在该集群中所有工作结点共享``NCCL_ID`` 。 +调用 ``transpile_nccl2`` 后, 你 **必须** 将 ``trainer_id`` , ``num_trainers`` 参数提供给 ``ParallelExecutor`` 来启动NCCL2分布式模式。 + + + + +**代码示例** + +.. code-block:: python + + # for pserver mode + pserver_endpoints = "192.168.0.1:6174,192.168.0.2:6174" + trainer_endpoints = "192.168.0.1:6174,192.168.0.2:6174" + current_endpoint = "192.168.0.1:6174" + trainer_id = 0 + trainers = 4 + role = os.getenv("PADDLE_TRAINING_ROLE") + + t = fluid.DistributeTranspiler() + t.transpile( + trainer_id, pservers=pserver_endpoints, trainers=trainers) + if role == "PSERVER": + pserver_program = t.get_pserver_program(current_endpoint) + pserver_startup_program = t.get_startup_program(current_endpoint, + pserver_program) + elif role == "TRAINER": + trainer_program = t.get_trainer_program() + + # for nccl2 mode + config = fluid.DistributeTranspilerConfig() + config.mode = "nccl2" + t = fluid.DistributeTranspiler(config=config) + t.transpile(trainer_id, workers=workers, current_endpoint=curr_ep) + exe = fluid.ParallelExecutor( + use_cuda, + loss_name=loss_var.name, + num_trainers=len(trainers.split(",)), + trainer_id=trainer_id + ) + + + +.. py:method:: transpile(trainer_id, program=None, pservers='127.0.0.1:6174', trainers=1, sync_mode=True, startup_program=None, current_endpoint='127.0.0.1:6174') + +该方法可以运行该transpiler(转译器)。 + +参数: + - **trainer_id** (int) – 当前Trainer worker的id, 如果有n个Trainer worker, id 取值范围为0 ~ n-1 + - **program** (Program|None) – 待transpile(转译)的program, 缺省为 ``fluid.default_main_program()`` + - **startup_program** (Program|None) - 要转译的 ``startup_program`` ,默认为 ``fluid.default_startup_program()`` + - **pservers** (str) – 内容为Pserver列表的字符串,格式为:按逗号区分不同的Pserver,每个Pserver的格式为 *ip地址:端口号* + - **trainers** (int|str) – 在Pserver模式下,该参数指Trainer机的个数;在nccl2模式下,它是一个内容为Trainer终端列表的字符串 + - **sync_mode** (bool) – 是否做同步训练(synchronous training), 默认为True + - **startup_program** (Program|None) – 待transpile(转译)的startup_program,默认为 ``fluid.default_main_program()`` + - **current_endpoint** (str) – 当需要把program转译(transpile)至NCCL2模式下时,需要将当前endpoint(终端)传入该参数。Pserver模式不使用该参数 + +.. py:method:: get_trainer_program(wait_port=True) + + +该方法可以得到Trainer侧的program。 + +返回: Trainer侧的program + +返回类型: Program + + + +.. py:method:: get_pserver_program(endpoint) + + +该方法可以得到Pserver(参数服务器)侧的程序 + +参数: + - **endpoint** (str) – 当前Pserver终端 + +返回: 当前Pserver需要执行的program + +返回类型: Program + + +.. py:method:: get_pserver_programs(endpoint) + + +该方法可以得到Pserver侧用于分布式训练的 ``main_program`` 和 ``startup_program`` 。 + +参数: + - **endpoint** (str) – 当前Pserver终端 + +返回: (main_program, startup_program), “Program”类型的元组 + +返回类型: tuple + + +.. py:method:: get_startup_program(endpoint, pserver_program=None, startup_program=None) + + +**该函数已停止使用** +获取当前Pserver的startup_program,如果有多个被分散到不同blocks的变量,则修改operator的输入变量。 + +参数: + - **endpoint** (str) – 当前Pserver终端 + - **pserver_program** (Program) – 已停止使用。 先调用get_pserver_program + - **startup_program** (Program) – 已停止使用。应在初始化时传入startup_program + +返回: Pserver侧的startup_program + +返回类型: Program + + + + + + + +.. _cn_api_fluid_transpiler_DistributeTranspilerConfig: + +DistributeTranspilerConfig +------------------------------- + +.. py:class:: paddle.fluid.transpiler.DistributeTranspilerConfig + +.. py:method:: slice_var_up (bool) + +为Pserver将张量切片, 默认为True + +.. py:method:: split_method (PSDispatcher) + +可使用 RoundRobin 或者 HashName + +注意: 尝试选择最佳方法来达到负载均衡。 + + +.. py:attribute:: min_block_size (int) + +最小数据块的大小 + +注意: 根据:https://github.com/PaddlePaddle/Paddle/issues/8638#issuecomment-369912156, 当数据块大小超过2MB时,我们可以有效地使用带宽。如果你想更改它,请详细查看slice_variable函数。 + + + + + + + +.. _cn_api_fluid_transpiler_HashName: + +HashName +------------------------------- + +.. py:class:: paddle.fluid.transpiler.HashName(pserver_endpoints) + +使用 python ``Hash()`` 函数将变量名散列到多个pserver终端。 + +参数: + - **pserver_endpoints** (list) - endpoint (ip:port)的 list + + + + + + + + +.. _cn_api_fluid_transpiler_memory_optimize: + +memory_optimize +------------------------------- + +.. py:function:: paddle.fluid.transpiler.memory_optimize(input_program, skip_opt_set=None, print_log=False, level=0, skip_grads=False) + +通过重用var内存来优化内存。 + +注意:它不支持block中嵌套子block。 + +参数: + - **input_program** (str) – 输入Program。 + - **skip_opt_set** (set) – set中的vars将不被内存优化。 + - **print_log** (bool) – 是否打印debug日志。 + - **level** (int) - 如果 level=0 并且shape是完全相等,则重用。 + +返回: None + + + + + + + + +.. _cn_api_fluid_transpiler_release_memory: + +release_memory +------------------------------- + +.. py:function:: paddle.fluid.transpiler.release_memory(input_program, skip_opt_set=None) + + +该函数可以调整输入program,插入 ``delete_op`` 删除算子,提前删除不需要的变量。 +改动是在变量本身上进行的。 + +**提醒** : 该API还在试验阶段,会在后期版本中删除。不建议用户使用。 + +参数: + - **input_program** (Program) – 在此program中插入 ``delete_op`` + - **skip_opt_set** (set) – 在内存优化时跳过的变量的集合 + +返回: None + + + + + + + + + + + + + + + +.. _cn_api_fluid_transpiler_RoundRobin: + +RoundRobin +------------------------------- + +.. py:class:: paddle.fluid.transpiler.RoundRobin(pserver_endpoints) + +使用 ``RondRobin`` 方法将变量分配给服务器端点。 + +`RondRobin `_ + +参数: + - **pserver_endpoints** (list) - endpoint (ip:port)的 list + + + + + + + +