未验证 提交 16922e00 编写于 作者: T Tao Luo 提交者: GitHub

fix api_example of tree_conv (#17239)

test=develop
上级 ef66baed
...@@ -227,7 +227,7 @@ paddle.fluid.layers.psroi_pool (ArgSpec(args=['input', 'rois', 'output_channels' ...@@ -227,7 +227,7 @@ paddle.fluid.layers.psroi_pool (ArgSpec(args=['input', 'rois', 'output_channels'
paddle.fluid.layers.teacher_student_sigmoid_loss (ArgSpec(args=['input', 'label', 'soft_max_up_bound', 'soft_max_lower_bound'], varargs=None, keywords=None, defaults=(15.0, -15.0)), ('document', '2f6ff96864054a31aa4bb659c6722c99')) paddle.fluid.layers.teacher_student_sigmoid_loss (ArgSpec(args=['input', 'label', 'soft_max_up_bound', 'soft_max_lower_bound'], varargs=None, keywords=None, defaults=(15.0, -15.0)), ('document', '2f6ff96864054a31aa4bb659c6722c99'))
paddle.fluid.layers.huber_loss (ArgSpec(args=['input', 'label', 'delta'], varargs=None, keywords=None, defaults=None), ('document', '431a4301c35032166ec029f7432c80a7')) paddle.fluid.layers.huber_loss (ArgSpec(args=['input', 'label', 'delta'], varargs=None, keywords=None, defaults=None), ('document', '431a4301c35032166ec029f7432c80a7'))
paddle.fluid.layers.kldiv_loss (ArgSpec(args=['x', 'target', 'reduction', 'name'], varargs=None, keywords=None, defaults=('mean', None)), ('document', '776d536cac47c89073abc7ee524d5aec')) paddle.fluid.layers.kldiv_loss (ArgSpec(args=['x', 'target', 'reduction', 'name'], varargs=None, keywords=None, defaults=('mean', None)), ('document', '776d536cac47c89073abc7ee524d5aec'))
paddle.fluid.layers.tree_conv (ArgSpec(args=['nodes_vector', 'edge_set', 'output_size', 'num_filters', 'max_depth', 'act', 'param_attr', 'bias_attr', 'name'], varargs=None, keywords=None, defaults=(1, 2, 'tanh', None, None, None)), ('document', '34ea12ac9f10a65dccbc50100d12e607')) paddle.fluid.layers.tree_conv (ArgSpec(args=['nodes_vector', 'edge_set', 'output_size', 'num_filters', 'max_depth', 'act', 'param_attr', 'bias_attr', 'name'], varargs=None, keywords=None, defaults=(1, 2, 'tanh', None, None, None)), ('document', '2985a372ac897ea4e13aced7f930d6f8'))
paddle.fluid.layers.npair_loss (ArgSpec(args=['anchor', 'positive', 'labels', 'l2_reg'], varargs=None, keywords=None, defaults=(0.002,)), ('document', '46994d10276dd4cb803b4062b5d14329')) paddle.fluid.layers.npair_loss (ArgSpec(args=['anchor', 'positive', 'labels', 'l2_reg'], varargs=None, keywords=None, defaults=(0.002,)), ('document', '46994d10276dd4cb803b4062b5d14329'))
paddle.fluid.layers.pixel_shuffle (ArgSpec(args=['x', 'upscale_factor'], varargs=None, keywords=None, defaults=None), ('document', '132b6e74ff642a392bd6b14c10aedc65')) paddle.fluid.layers.pixel_shuffle (ArgSpec(args=['x', 'upscale_factor'], varargs=None, keywords=None, defaults=None), ('document', '132b6e74ff642a392bd6b14c10aedc65'))
paddle.fluid.layers.fsp_matrix (ArgSpec(args=['x', 'y'], varargs=None, keywords=None, defaults=None), ('document', 'b76ccca3735bea4a58a0dbf0d77c5393')) paddle.fluid.layers.fsp_matrix (ArgSpec(args=['x', 'y'], varargs=None, keywords=None, defaults=None), ('document', 'b76ccca3735bea4a58a0dbf0d77c5393'))
......
...@@ -11051,21 +11051,19 @@ def tree_conv(nodes_vector, ...@@ -11051,21 +11051,19 @@ def tree_conv(nodes_vector,
Examples: Examples:
.. code-block:: python .. code-block:: python
nodes_vector = layers.data(name='vectors', shape=[None, 10, 5], dtype='float32) # 10 for max_node_size of dataset, 5 for vector width
# None for batch size, 10 for max_node_size of dataset, 5 for vector width nodes_vector = fluid.layers.data(name='vectors', shape=[10, 5], dtype='float32')
edge_set = layers.data(name='edge_set', shape=[None, 10, 2], dtype='float32') # 10 for max_node_size of dataset, 2 for every edge has two nodes
# None for batch size, 10 for max_node_size of dataset, 2 for every edge has two nodes
# edges must be directional # edges must be directional
out_vector = layers.tree_conv(nodes_vector, edge_set, 6, 1, 2, 'tanh', edge_set = fluid.layers.data(name='edge_set', shape=[10, 2], dtype='float32')
ParamAttr(initializer=Constant(1.0), ParamAttr(initializer=Constant(1.0)) # the shape of output will be [10, 6, 1],
# the shape of output will be [None, 10, 6, 1], # 10 for max_node_size of dataset, 6 for output size, 1 for 1 filter
# None for batch size, 10 for max_node_size of dataset, 6 for output size, 1 for 1 filter out_vector = fluid.layers.tree_conv(nodes_vector, edge_set, 6, 1, 2)
out_vector = layers.reshape(out_vector, shape=[None, 10, 6])
# After reshape, output tensor could be nodes_vector for next tree convolution # After reshape, output tensor could be nodes_vector for next tree convolution
out_vector_2 = layers.tree_conv(out_vector, edge_set, 3, 4, 2, 'tanh', out_vector = fluid.layers.reshape(out_vector, shape=[-1, 10, 6])
ParamAttr(initializer=Constant(1.0), ParamAttr(initializer=Constant(1.0)) out_vector_2 = fluid.layers.tree_conv(out_vector, edge_set, 3, 4, 2)
# also output tensor could be pooling(the pooling in paper called global pooling) # also output tensor could be pooling(the pooling in paper called global pooling)
pooled = layers.reduce_max(out_vector, dims=2) # global pooling pooled = fluid.layers.reduce_max(out_vector, dim=2) # global pooling
""" """
helper = LayerHelper("tree_conv", **locals()) helper = LayerHelper("tree_conv", **locals())
dtype = helper.input_dtype('nodes_vector') dtype = helper.input_dtype('nodes_vector')
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册