未验证 提交 77cc0ff6 编写于 作者: T Tao Luo 提交者: GitHub

update name_scope document (#1493)

上级 802e8d2d
......@@ -6,7 +6,7 @@ name_scope
.. py:function:: paddle.fluid.name_scope(prefix=None)
OP为operators生成不同的命名空间。此OP用于调试和可视化,不建议用在其它方面。
函数为operators生成不同的命名空间。该函数只用于调试和可视化,不建议用在其它方面。
参数:
......@@ -18,7 +18,7 @@ name_scope
import paddle.fluid as fluid
with fluid.name_scope("s1"):
a = fluid.layers.data(name='data', shape=[1], dtype='int32')
a = fluid.data(name='data', shape=[None, 1], dtype='int32')
b = a + 1
with fluid.name_scope("s2"):
c = b * 1
......@@ -33,18 +33,16 @@ name_scope
for op in fluid.default_main_program().block(0).ops:
# elementwise_add在/s1/中创建
if op.type == 'elementwise_add':
self.assertEqual(op.desc.attr("op_namescope"), '/s1/')
assert op.desc.attr("op_namescope") == '/s1/'
# elementwise_mul在/s1/s2中创建
elif op.type == 'elementwise_mul':
self.assertEqual(op.desc.attr("op_namescope"), '/s1/s2/')
assert op.desc.attr("op_namescope") == '/s1/s2/'
# elementwise_div在/s1/s3中创建
elif op.type == 'elementwise_div':
self.assertEqual(op.desc.attr("op_namescope"), '/s1/s3/')
assert op.desc.attr("op_namescope") == '/s1/s3/'
# elementwise_sum在/s4/中创建
elif op.type == 'elementwise_sub':
self.assertEqual(op.desc.attr("op_namescope"), '/s4/')
assert op.desc.attr("op_namescope") == '/s4/'
# pow在/s1_1/中创建
elif op.type == 'pow':
self.assertEqual(op.desc.attr("op_namescope"), '/s1_1/')
assert op.desc.attr("op_namescope") == '/s1_1/'
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册