From 68be3ab288cfe7fecc4f850d02f1522c13a959be Mon Sep 17 00:00:00 2001 From: cuicheng01 <45199522+cuicheng01@users.noreply.github.com> Date: Sun, 29 Nov 2020 18:09:48 +0800 Subject: [PATCH] Fix some minor bugs to adapt to paddle2.0rc. (#431) * Update mobilenet_v3.py * Update densenet.py * Update resnest.py * Update hrnet.py * Update vgg.py * Update xception.py --- ppcls/modeling/architectures/densenet.py | 2 +- ppcls/modeling/architectures/hrnet.py | 2 +- ppcls/modeling/architectures/mobilenet_v3.py | 2 +- ppcls/modeling/architectures/resnest.py | 4 ++-- ppcls/modeling/architectures/vgg.py | 2 +- ppcls/modeling/architectures/xception.py | 2 +- 6 files changed, 7 insertions(+), 7 deletions(-) diff --git a/ppcls/modeling/architectures/densenet.py b/ppcls/modeling/architectures/densenet.py index cc739155..dfef9a6d 100644 --- a/ppcls/modeling/architectures/densenet.py +++ b/ppcls/modeling/architectures/densenet.py @@ -278,7 +278,7 @@ class DenseNet(nn.Layer): conv = self.batch_norm(conv) y = self.pool2d_avg(conv) - y = paddle.reshape(y, shape=[0, -1]) + y = paddle.reshape(y, shape=[-1, y.shape[1]]) y = self.out(y) return y diff --git a/ppcls/modeling/architectures/hrnet.py b/ppcls/modeling/architectures/hrnet.py index 697441f9..9994a516 100644 --- a/ppcls/modeling/architectures/hrnet.py +++ b/ppcls/modeling/architectures/hrnet.py @@ -657,7 +657,7 @@ class HRNet(nn.Layer): y = self.conv_last(y) y = self.pool2d_avg(y) - y = paddle.reshape(y, shape=[0, -1]) + y = paddle.reshape(y, shape=[-1, y.shape[1]]) y = self.out(y) return y diff --git a/ppcls/modeling/architectures/mobilenet_v3.py b/ppcls/modeling/architectures/mobilenet_v3.py index f25782d1..d179c221 100644 --- a/ppcls/modeling/architectures/mobilenet_v3.py +++ b/ppcls/modeling/architectures/mobilenet_v3.py @@ -306,7 +306,7 @@ class SEModule(nn.Layer): outputs = F.relu(outputs) outputs = self.conv2(outputs) outputs = hard_sigmoid(outputs) - return paddle.multiply(x=inputs, y=outputs, axis=0) + return paddle.multiply(x=inputs, y=outputs) def MobileNetV3_small_x0_35(**args): diff --git a/ppcls/modeling/architectures/resnest.py b/ppcls/modeling/architectures/resnest.py index 0820ba28..eb6f8bef 100644 --- a/ppcls/modeling/architectures/resnest.py +++ b/ppcls/modeling/architectures/resnest.py @@ -85,11 +85,11 @@ class rSoftmax(nn.Layer): x = paddle.reshape( x=x, shape=[ - 0, cardinality, radix, int(r * h * w / cardinality / radix) + batch, cardinality, radix, int(r * h * w / cardinality / radix) ]) x = paddle.transpose(x=x, perm=[0, 2, 1, 3]) x = nn.functional.softmax(x, axis=1) - x = paddle.reshape(x=x, shape=[0, r * h * w]) + x = paddle.reshape(x=x, shape=[batch, r * h * w]) else: x = nn.functional.sigmoid(x) return x diff --git a/ppcls/modeling/architectures/vgg.py b/ppcls/modeling/architectures/vgg.py index 27619c31..ccb94a9f 100644 --- a/ppcls/modeling/architectures/vgg.py +++ b/ppcls/modeling/architectures/vgg.py @@ -113,7 +113,7 @@ class VGGNet(nn.Layer): x = self._conv_block_4(x) x = self._conv_block_5(x) - x = paddle.reshape(x, [0, -1]) + x = paddle.reshape(x, [-1, x.shape[1]*x.shape[2]*x.shape[3]]) x = self._fc1(x) x = F.relu(x) x = self._drop(x) diff --git a/ppcls/modeling/architectures/xception.py b/ppcls/modeling/architectures/xception.py index cf2ea35a..61c87ab4 100644 --- a/ppcls/modeling/architectures/xception.py +++ b/ppcls/modeling/architectures/xception.py @@ -305,7 +305,7 @@ class ExitFlow(nn.Layer): conv2 = self._conv_2(conv1) conv2 = F.relu(conv2) pool = self._pool(conv2) - pool = paddle.reshape(pool, [0, -1]) + pool = paddle.reshape(pool, [-1, pool.shape[1]]) out = self._out(pool) return out -- GitLab