Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

modify some cn doc #2710

Merged
merged 5 commits into from
Sep 30, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/paddle/api/alias_api_mapping
Original file line number Diff line number Diff line change
Expand Up @@ -569,3 +569,6 @@ paddle.metric.metrics.Accuracy paddle.metric.Accuracy
paddle.metric.metrics.Precision paddle.metric.Precision
paddle.metric.metrics.Recall paddle.metric.Recall
paddle.metric.metrics.Auc paddle.metric.Auc
paddle.fluid.unique_name.guard paddle.utils.unique_name.guard
paddle.fluid.unique_name.switch paddle.utils.unique_name.switch
paddle.fluid.unique_name.generate paddle.utils.unique_name.generate
1 change: 0 additions & 1 deletion doc/paddle/api/not_display_doc_list
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
paddle.utils
paddle.incubate
paddle.hapi.progressbar.ProgressBar
paddle.fluid.contrib
Expand Down
36 changes: 17 additions & 19 deletions doc/paddle/api/paddle/fluid/dygraph/container/Sequential_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
Sequential
-------------------------------

.. py:class:: paddle.fluid.dygraph.Sequential(*layers)
.. py:class:: paddle.nn.Sequential(*layers)



Expand All @@ -19,24 +19,22 @@ Sequential

.. code-block:: python

import paddle.fluid as fluid
import paddle
import numpy as np
data = np.random.uniform(-1, 1, [30, 10]).astype('float32')
with fluid.dygraph.guard():
data = fluid.dygraph.to_variable(data)
# 使用 iterable Layers 创建 Sequential 容器
model1 = fluid.dygraph.Sequential(
fluid.Linear(10, 1), fluid.Linear(1, 2)
)
model1[0] # 访问第一个子层
res1 = model1(data) # 顺序执行
# 使用 iterable name Layer 对创建 Sequential 容器
model2 = fluid.dygraph.Sequential(
('l1', fluid.Linear(10, 2)),
('l2', fluid.Linear(2, 3))
)
model2['l1'] # 访问 l1 子层
model2.add_sublayer('l3', fluid.Linear(3, 3)) # 添加子层
res2 = model2(data) # 顺序执行

data = paddle.to_tensor(data)
# create Sequential with iterable Layers
model1 = paddle.nn.Sequential(
paddle.nn.Linear(10, 1), paddle.nn.Linear(1, 2)
)
model1[0] # access the first layer
res1 = model1(data) # sequential execution
# create Sequential with name Layer pairs
model2 = paddle.nn.Sequential(
('l1', paddle.nn.Linear(10, 2)),
('l2', paddle.nn.Linear(2, 3))
)
model2['l1'] # access l1 layer
model2.add_sublayer('l3', paddle.nn.Linear(3, 3)) # add sublayer
res2 = model2(data) # sequential execution

Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ bilinear_tensor_product
-------------------------------


.. py:function:: paddle.fluid.layers.bilinear_tensor_product(x, y, size, act=None, name=None, param_attr=None, bias_attr=None)
.. py:function:: paddle.static.nn.bilinear_tensor_product(x, y, size, act=None, name=None, param_attr=None, bias_attr=None)



Expand Down Expand Up @@ -32,19 +32,17 @@ bilinear_tensor_product
- **param_attr** (ParamAttr,可选) :指定权重参数属性的对象。默认值为 None,表示使用默认的权重参数属性。具体用法请参见 :ref:`cn_api_fluid_ParamAttr` 。
- **bias_attr** (ParamAttr,可选) : 指定偏置参数属性的对象。默认值为 None,表示使用默认的偏置参数属性。具体用法请参见 :ref:`cn_api_fluid_ParamAttr` 。

返回: 一个形为 [batch_size, size] 的 2-D 张量。

返回类型:Variable
返回: Variable, 一个形为 [batch_size, size] 的 2-D 张量。

**代码示例:**

.. code-block:: python

import paddle.fluid as fluid
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

返回类型 和 返回写在一起哈,如
【返回:Variable,一个xxx】

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done,thx!

layer1 = fluid.layers.data("t1", shape=[-1, 5], dtype="float32")
layer2 = fluid.layers.data("t2", shape=[-1, 4], dtype="float32")
tensor = fluid.layers.bilinear_tensor_product(x=layer1, y=layer2, size=1000)

import paddle
paddle.enable_static()
layer1 = paddle.static.data("t1", shape=[-1, 5], dtype="float32")
layer2 = paddle.static.data("t2", shape=[-1, 4], dtype="float32")
tensor = paddle.static.nn.bilinear_tensor_product(x=layer1, y=layer2, size=1000)



15 changes: 6 additions & 9 deletions doc/paddle/api/paddle/fluid/unique_name/generate_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
generate
-------------------------------

.. py:function:: paddle.fluid.unique_name.generate(key)
.. py:function:: paddle.utils.unique_name.generate(key)



Expand All @@ -13,17 +13,14 @@ generate
参数:
- **key** (str) - 产生的唯一名称的前缀。

返回:含前缀key的唯一名称。

返回类型:str。
返回:str, 含前缀key的唯一名称。

**代码示例**

.. code-block:: python
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

返回类型同上

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done,thx!


import paddle.fluid as fluid
name1 = fluid.unique_name.generate('fc')
name2 = fluid.unique_name.generate('fc')
print(name1, name2) # fc_0, fc_1

import paddle
name1 = paddle.utils.unique_name.generate('fc')
name2 = paddle.utils.unique_name.generate('fc')
print(name1, name2) # fc_0, fc_1

27 changes: 13 additions & 14 deletions doc/paddle/api/paddle/fluid/unique_name/guard_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
guard
-------------------------------

.. py:function:: paddle.fluid.unique_name.guard(new_generator=None)
.. py:function:: paddle.utils.unique_name.guard(new_generator=None)



Expand All @@ -19,17 +19,16 @@ guard

.. code-block:: python

import paddle.fluid as fluid
with fluid.unique_name.guard():
name_1 = fluid.unique_name.generate('fc')
with fluid.unique_name.guard():
name_2 = fluid.unique_name.generate('fc')
print(name_1, name_2) # fc_0, fc_0

with fluid.unique_name.guard('A'):
name_1 = fluid.unique_name.generate('fc')
with fluid.unique_name.guard('B'):
name_2 = fluid.unique_name.generate('fc')
print(name_1, name_2) # Afc_0, Bfc_0

import paddle
with paddle.utils.unique_name.guard():
name_1 = paddle.utils.unique_name.generate('fc')
with paddle.utils.unique_name.guard():
name_2 = paddle.utils.unique_name.generate('fc')
print(name_1, name_2) # fc_0, fc_0

with paddle.utils.unique_name.guard('A'):
name_1 = paddle.utils.unique_name.generate('fc')
with paddle.utils.unique_name.guard('B'):
name_2 = paddle.utils.unique_name.generate('fc')
print(name_1, name_2) # Afc_0, Bfc_0

30 changes: 14 additions & 16 deletions doc/paddle/api/paddle/fluid/unique_name/switch_cn.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
switch
-------------------------------

.. py:function:: paddle.fluid.unique_name.switch(new_generator=None)
.. py:function:: paddle.utils.unique_name.switch(new_generator=None)



Expand All @@ -13,23 +13,21 @@ switch
参数:
- **new_generator** (UniqueNameGenerator, 可选) - 要切换到的新命名空间,一般无需设置。缺省值为None,表示切换到一个匿名的新命名空间。

返回:先前的命名空间,一般无需操作该返回值。

返回类型:UniqueNameGenerator。
返回:UniqueNameGenerator, 先前的命名空间,一般无需操作该返回值。

**代码示例**

.. code-block:: python
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

返回类型同上

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done,thx!


import paddle.fluid as fluid
name1 = fluid.unique_name.generate('fc')
name2 = fluid.unique_name.generate('fc')
print(name1, name2) # fc_0, fc_1
pre_generator = fluid.unique_name.switch() # 切换到新命名空间
name2 = fluid.unique_name.generate('fc')
print(name2) # fc_0

fluid.unique_name.switch(pre_generator) # 切换回原命名空间
name3 = fluid.unique_name.generate('fc')
print(name3) # fc_2, 因为原命名空间已生成fc_0, fc_1
import paddle
name1 = paddle.utils.unique_name.generate('fc')
name2 = paddle.utils.unique_name.generate('fc')
print(name1, name2) # fc_0, fc_1

pre_generator, pre_dygraph_name_checker = paddle.utils.unique_name.switch() # switch to a new anonymous namespace.
name2 = paddle.utils.unique_name.generate('fc')
print(name2) # fc_0

paddle.utils.unique_name.switch(pre_generator, pre_dygraph_name_checker) # switch back to pre_generator.
name3 = paddle.utils.unique_name.generate('fc')
print(name3) # fc_2, since pre_generator has generated fc_0, fc_1.