Skip to content

Commit 243e816

Browse files
refine paddle.shape (#3703)
1 parent 63b0fcc commit 243e816

File tree

6 files changed

+8
-8
lines changed

6 files changed

+8
-8
lines changed

paddleseg/models/decoupled_segnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -206,7 +206,7 @@ def __init__(self, inplane, align_corners=False):
206206
bias_attr=False)
207207

208208
def forward(self, x):
209-
size = x.shape[2:]
209+
size = paddle.shape(x)[2:]
210210
seg_down = self.down(x)
211211
seg_down = F.interpolate(seg_down,
212212
size=size,

paddleseg/models/ginet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ def forward(self, x, inp):
184184
sizeB = B.shape
185185
B = paddle.flatten(B, 2, 3)
186186

187-
sizex = x.shape
187+
sizex = paddle.shape(x)
188188
x_reduce = self.conv_phi(x)
189189

190190
x_reduce = paddle.flatten(x_reduce, 2, 3).transpose((0, 2, 1))

paddleseg/models/isanet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def __init__(self, num_classes, in_channels, isa_channels, down_factor,
122122
def forward(self, feat_list):
123123
C3, C4 = feat_list
124124
x = self.in_conv(C4)
125-
x_shape = x.shape
125+
x_shape = paddle.shape(x)
126126
P_h, P_w = self.down_factor
127127
Q_h, Q_w = paddle.ceil(x_shape[2:3] / P_h).astype('int32'), paddle.ceil(
128128
x_shape[3:4] / P_w).astype('int32')

paddleseg/models/losses/pixel_contrast_cross_entropy_loss.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ def _hard_anchor_sampling(self, X, y_hat, y):
5757
y_hat (Tensor): reshaped label, shape = [N, H * W]
5858
y (Tensor): reshaped predict, shape = [N, H * W]
5959
"""
60-
batch_size, feat_dim = x.shape[0], x.shape[-1]
60+
batch_size, feat_dim = X.shape[0], X.shape[-1]
6161
classes = []
6262
total_classes = 0
6363
for i in range(batch_size):

paddleseg/models/pointrend.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -420,9 +420,9 @@ def get_points_test(self, seg_logits, uncertainty_func): # finish
420420

421421
num_points = self.subdivision_num_points
422422
uncertainty_map = uncertainty_func(seg_logits)
423-
batch_size = uncertainty_map.shape[0:1]
424-
height = uncertainty_map.shape[2:3]
425-
width = uncertainty_map.shape[3:4]
423+
batch_size = paddle.shape(uncertainty_map)[0:1]
424+
height = paddle.shape(uncertainty_map)[2:3]
425+
width = paddle.shape(uncertainty_map)[3:4]
426426
h_step = 1.0 / height
427427
w_step = 1.0 / width
428428

paddleseg/models/sfnet.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,7 @@ def flow_warp(self, input, flow, size):
221221
def forward(self, x):
222222
low_feature, h_feature = x
223223
h_feature_orign = h_feature
224-
size = low_feature.shape[2:]
224+
size = paddle.shape(low_feature)[2:]
225225
low_feature = self.down_l(low_feature)
226226
h_feature = self.down_h(h_feature)
227227
h_feature = F.interpolate(h_feature,

0 commit comments

Comments
 (0)