From 15b561d7b2498d5d6ad5fa038ec8310ecbe1c0e8 Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Thu, 14 May 2020 18:01:12 +0800 Subject: [PATCH] Update API usage according to 1.8 recommendations (#666) --- ppdet/ext_op/test/test_corner_pool.py | 2 +- ppdet/modeling/anchor_heads/fcos_head.py | 14 +++----------- ppdet/modeling/architectures/fcos.py | 2 +- ppdet/modeling/backbones/bfp.py | 2 +- ppdet/modeling/backbones/cb_resnet.py | 3 +-- ppdet/modeling/backbones/hrfpn.py | 2 +- 6 files changed, 8 insertions(+), 17 deletions(-) diff --git a/ppdet/ext_op/test/test_corner_pool.py b/ppdet/ext_op/test/test_corner_pool.py index ee5e6b07d..b0d10b893 100755 --- a/ppdet/ext_op/test/test_corner_pool.py +++ b/ppdet/ext_op/test/test_corner_pool.py @@ -83,7 +83,7 @@ class TestRightPoolOp(unittest.TestCase): place = fluid.CUDAPlace(0) with fluid.program_guard(tp, sp): - x = fluid.layers.data( + x = fluid.data( name=self.name, shape=x_shape, dtype=x_type, diff --git a/ppdet/modeling/anchor_heads/fcos_head.py b/ppdet/modeling/anchor_heads/fcos_head.py index 9b5c4b3c0..32ccc391c 100644 --- a/ppdet/modeling/anchor_heads/fcos_head.py +++ b/ppdet/modeling/anchor_heads/fcos_head.py @@ -283,22 +283,14 @@ class FCOSHead(object): last dimension is [x1, y1, x2, y2] """ act_shape_cls = self.__merge_hw(box_cls) - box_cls_ch_last = fluid.layers.reshape( - x=box_cls, - shape=[self.batch_size, self.num_classes, -1], - actual_shape=act_shape_cls) + box_cls_ch_last = fluid.layers.reshape(x=box_cls, shape=act_shape_cls) box_cls_ch_last = fluid.layers.sigmoid(box_cls_ch_last) act_shape_reg = self.__merge_hw(box_reg, "channel_last") box_reg_ch_last = fluid.layers.transpose(box_reg, perm=[0, 2, 3, 1]) box_reg_ch_last = fluid.layers.reshape( - x=box_reg_ch_last, - shape=[self.batch_size, -1, 4], - actual_shape=act_shape_reg) + x=box_reg_ch_last, shape=act_shape_reg) act_shape_ctn = self.__merge_hw(box_ctn) - box_ctn_ch_last = fluid.layers.reshape( - x=box_ctn, - shape=[self.batch_size, 1, -1], - actual_shape=act_shape_ctn) + box_ctn_ch_last = fluid.layers.reshape(x=box_ctn, shape=act_shape_ctn) box_ctn_ch_last = fluid.layers.sigmoid(box_ctn_ch_last) box_reg_decoding = fluid.layers.stack( diff --git a/ppdet/modeling/architectures/fcos.py b/ppdet/modeling/architectures/fcos.py index 3d5709cfe..bb81a7e3d 100644 --- a/ppdet/modeling/architectures/fcos.py +++ b/ppdet/modeling/architectures/fcos.py @@ -162,7 +162,7 @@ class FCOS(object): for i in range(len(self.fcos_head.fpn_stride)): fields.extend( ['labels%d' % i, 'reg_target%d' % i, 'centerness%d' % i]) - feed_vars = OrderedDict([(key, fluid.layers.data( + feed_vars = OrderedDict([(key, fluid.data( name=key, shape=inputs_def[key]['shape'], dtype=inputs_def[key]['dtype'], diff --git a/ppdet/modeling/backbones/bfp.py b/ppdet/modeling/backbones/bfp.py index 1dc03de69..6bafc68c9 100644 --- a/ppdet/modeling/backbones/bfp.py +++ b/ppdet/modeling/backbones/bfp.py @@ -152,5 +152,5 @@ class BFP(object): out_shape = fluid.layers.cast(out_shape_, dtype='int32') out_shape.stop_gradient = True body_output = fluid.layers.resize_nearest( - body_input, scale=scale, actual_shape=out_shape) + body_input, scale=scale, out_shape=out_shape) return body_output diff --git a/ppdet/modeling/backbones/cb_resnet.py b/ppdet/modeling/backbones/cb_resnet.py index dc1ca209a..3da5757bd 100644 --- a/ppdet/modeling/backbones/cb_resnet.py +++ b/ppdet/modeling/backbones/cb_resnet.py @@ -401,8 +401,7 @@ class CBResNet(object): out_shape_ = shape_hw out_shape = fluid.layers.cast(out_shape_, dtype='int32') out_shape.stop_gradient = True - conv = fluid.layers.resize_nearest( - conv, scale=2., actual_shape=out_shape) + conv = fluid.layers.resize_nearest(conv, scale=2., out_shape=out_shape) output = fluid.layers.elementwise_add(x=right, y=conv) return output diff --git a/ppdet/modeling/backbones/hrfpn.py b/ppdet/modeling/backbones/hrfpn.py index 37377f121..174c6d10d 100644 --- a/ppdet/modeling/backbones/hrfpn.py +++ b/ppdet/modeling/backbones/hrfpn.py @@ -120,7 +120,7 @@ class HRFPN(object): out_shape = fluid.layers.cast(out_shape_, dtype='int32') out_shape.stop_gradient = True body_output = fluid.layers.resize_bilinear( - body_input, scale=scale, actual_shape=out_shape) + body_input, scale=scale, out_shape=out_shape) return body_output def pooling(self, input, size, stride, pooling_type): -- GitLab