XinJCheng / CSPN

Convolutional Spatial Propagation Network
496 stars 92 forks source link

Question about affinity matrix #54

Open lizechng opened 1 year ago

lizechng commented 1 year ago

Hi, i'm very interested in your excellent work, but confused on the affinity matrix.... At the code https://github.com/XinJCheng/CSPN/blob/b3e487bdcdcd8a63333656e69b3268698e543181/cspn_pytorch/models/torch_resnet_cspn_nyu.py#L372

guidance = self.gud_up_proj_layer6(x)

class Simple_Gudi_UpConv_Block_Last_Layer(nn.Module):
    def __init__(self, in_channels, out_channels, oheight=0, owidth=0):
        super(Simple_Gudi_UpConv_Block_Last_Layer, self).__init__()
        self.conv1 = nn.Conv2d(in_channels, out_channels, kernel_size=3, stride=1, padding=1, bias=False)
        self.oheight = oheight
        self.owidth = owidth
        self._up_pool = Unpool(in_channels)

    def _up_pooling(self, x, scale):

        x = self._up_pool(x)
        if self.oheight != 0 and self.owidth != 0:
            x = x.narrow(2, 0, self.oheight)
            x = x.narrow(3, 0, self.owidth)
        return x

    def forward(self, x):
        x = self._up_pooling(x, 2)
        out = self.conv1(x)
        return out

in function _up_pooling, with self._up_pool(x), the shape of x should be [batch, 8, 228*2, 304*2] and

x = x.narrow(2, 0, self.oheight)
x = x.narrow(3, 0, self.owidth)

the guidance feature's shape should be [batch, 8, 228, 304]

Why the guidance feature only retain the left-top area?

Looking forward to your reply.