From 9acdb6e83a6fc08d1a4328470ac3eea999644c5b Mon Sep 17 00:00:00 2001 From: chengjuntao <18222160892@163.com> Date: Thu, 10 Oct 2019 11:47:18 +0800 Subject: [PATCH] Fix fluid.data code example (#20236) * fix fluid.data code example, test=develop, test=document_preview, test=document_fix --- paddle/fluid/API.spec | 2 +- python/paddle/fluid/layers/nn.py | 92 +++++++++++++++----------------- 2 files changed, 45 insertions(+), 49 deletions(-) diff --git a/paddle/fluid/API.spec b/paddle/fluid/API.spec index f0dfa90c9d..2ae0008bce 100755 --- a/paddle/fluid/API.spec +++ b/paddle/fluid/API.spec @@ -305,7 +305,7 @@ paddle.fluid.layers.where (ArgSpec(args=['condition'], varargs=None, keywords=No paddle.fluid.layers.sign (ArgSpec(args=['x'], varargs=None, keywords=None, defaults=None), ('document', 'b56afe9ae3fc553c95d907fd7ef6c314')) paddle.fluid.layers.deformable_conv (ArgSpec(args=['input', 'offset', 'mask', 'num_filters', 'filter_size', 'stride', 'padding', 'dilation', 'groups', 'deformable_groups', 'im2col_step', 'param_attr', 'bias_attr', 'modulated', 'name'], varargs=None, keywords=None, defaults=(1, 0, 1, None, None, None, None, None, True, None)), ('document', '3e090f9e90b9c24d07348243bf137b56')) paddle.fluid.layers.unfold (ArgSpec(args=['x', 'kernel_sizes', 'strides', 'paddings', 'dilations', 'name'], varargs=None, keywords=None, defaults=(1, 0, 1, None)), ('document', '3f884662ad443d9ecc2b3734b4f61ad6')) -paddle.fluid.layers.deformable_roi_pooling (ArgSpec(args=['input', 'rois', 'trans', 'no_trans', 'spatial_scale', 'group_size', 'pooled_height', 'pooled_width', 'part_size', 'sample_per_part', 'trans_std', 'position_sensitive', 'name'], varargs=None, keywords=None, defaults=(False, 1.0, [1, 1], 1, 1, None, 1, 0.1, False, None)), ('document', '47c5d1c890b36fa00ff3285c9398f613')) +paddle.fluid.layers.deformable_roi_pooling (ArgSpec(args=['input', 'rois', 'trans', 'no_trans', 'spatial_scale', 'group_size', 'pooled_height', 'pooled_width', 'part_size', 'sample_per_part', 'trans_std', 'position_sensitive', 'name'], varargs=None, keywords=None, defaults=(False, 1.0, [1, 1], 1, 1, None, 1, 0.1, False, None)), ('document', 'e0e7bf35da2287efb015546f1b8350df')) paddle.fluid.layers.filter_by_instag (ArgSpec(args=['ins', 'ins_tag', 'filter_tag', 'is_lod'], varargs=None, keywords=None, defaults=None), ('document', '7703a2088af8de4128b143ff1164ca4a')) paddle.fluid.layers.shard_index (ArgSpec(args=['input', 'index_num', 'nshards', 'shard_id', 'ignore_value'], varargs=None, keywords=None, defaults=(-1,)), ('document', '3c6b30e9cd57b38d4a5fa1ade887f779')) paddle.fluid.layers.hard_swish (ArgSpec(args=['x', 'threshold', 'scale', 'offset', 'name'], varargs=None, keywords=None, defaults=(6.0, 6.0, 3.0, None)), ('document', '6a5152a7015c62cb8278fc24cb456459')) diff --git a/python/paddle/fluid/layers/nn.py b/python/paddle/fluid/layers/nn.py index 61ebc412a8..568b47fc2e 100755 --- a/python/paddle/fluid/layers/nn.py +++ b/python/paddle/fluid/layers/nn.py @@ -15734,57 +15734,53 @@ def deformable_roi_pooling(input, # position_sensitive=True import paddle.fluid as fluid - input = fluid.layers.data(name="input", - shape=[2, 192, 64, 64], - dtype='float32', - append_batch_size=False) - rois = fluid.layers.data(name="rois", - shape=[4], - dtype='float32', - lod_level=1) - trans = fluid.layers.data(name="trans", - shape=[2, 384, 64, 64], - dtype='float32', - append_batch_size=False) - x = fluid.layers.nn.deformable_roi_pooling(input=input, - rois=rois, - trans=trans, - no_trans=False, - spatial_scale=1.0, - group_size=(1, 1), - pooled_height=8, - pooled_width=8, - part_size=(8, 8), - sample_per_part=4, - trans_std=0.1, - position_sensitive=True) + input = fluid.data(name="input", + shape=[2, 192, 64, 64], + dtype='float32') + rois = fluid.data(name="rois", + shape=[-1, 4], + dtype='float32', + lod_level=1) + trans = fluid.data(name="trans", + shape=[2, 384, 64, 64], + dtype='float32') + x = fluid.layers.deformable_roi_pooling(input=input, + rois=rois, + trans=trans, + no_trans=False, + spatial_scale=1.0, + group_size=(1, 1), + pooled_height=8, + pooled_width=8, + part_size=(8, 8), + sample_per_part=4, + trans_std=0.1, + position_sensitive=True) # position_sensitive=False import paddle.fluid as fluid - input = fluid.layers.data(name="input", - shape=[2, 192, 64, 64], - dtype='float32', - append_batch_size=False) - rois = fluid.layers.data(name="rois", - shape=[4], - dtype='float32', - lod_level=1) - trans = fluid.layers.data(name="trans", - shape=[2, 384, 64, 64], - dtype='float32', - append_batch_size=False) - x = fluid.layers.nn.deformable_roi_pooling(input=input, - rois=rois, - trans=trans, - no_trans=False, - spatial_scale=1.0, - group_size=(1, 1), - pooled_height=8, - pooled_width=8, - part_size=(8, 8), - sample_per_part=4, - trans_std=0.1, - position_sensitive=False) + input = fluid.data(name="input", + shape=[2, 192, 64, 64], + dtype='float32') + rois = fluid.data(name="rois", + shape=[-1, 4], + dtype='float32', + lod_level=1) + trans = fluid.data(name="trans", + shape=[2, 384, 64, 64], + dtype='float32') + x = fluid.layers.deformable_roi_pooling(input=input, + rois=rois, + trans=trans, + no_trans=False, + spatial_scale=1.0, + group_size=(1, 1), + pooled_height=8, + pooled_width=8, + part_size=(8, 8), + sample_per_part=4, + trans_std=0.1, + position_sensitive=False) """ input_channels = input.shape[1] -- GitLab