dongzhang89 / SR-SS

Implementation for paper: Self-Regulation for Semantic Segmentation
31 stars 4 forks source link

Bug in ClassLayer? #3

Closed fjean closed 3 years ago

fjean commented 3 years ago

In the forward method of class ClassLayer in lib/models.deeplab.py:

def forward(self, x):
        x = self.layer(x)
        x = self.classification(x)
        pred = x.view(x.shape[0], -1)
        pred = torch.sigmoid(self.fc(pred))
        return x, pred

the returned x does not represent feature maps anymore because self.classification is an AdaptiveAvgPooling2D with output_size=1, and thus returns a tensor with shape BxCx1x1. Then this is resized to the size of the image later, which doesn't seem to make sense.

Shouldn't it be like this?

def forward(self, x):
        x = self.layer(x)
        pred = self.classification(x)
        pred = pred.view(pred.shape[0], -1)
        pred = torch.sigmoid(self.fc(pred))
        return x, pred
dongzhang89 commented 3 years ago

@fjean Thank you for your reminding. This bug has been fixed.