Skip to content

代码训练有点小问题 #4

Description

@icey-zhang

您好,您提供的链接没有关于ABCNet的训练代码,所以我自己写了一个,但是感觉这个模型定义是不是有点问题

class ABCNet(nn.Module):
    def __init__(self, band, n_classes):
        super(ABCNet, self).__init__()
        self.name = 'ABCNet'
        self.cp = ContextPath()
        self.sp = SpatialPath()
        self.fam = FeatureAggregationModule(256, 256)
        self.conv_out = Output(256, 256, n_classes, up_factor=8)
        if self.training:
            self.conv_out16 = Output(128, 64, n_classes, up_factor=8)
            self.conv_out32 = Output(128, 64, n_classes, up_factor=16)
        self.init_weight()

    def forward(self, x):
        H, W = x.size()[2:]
        feat_cp8, feat_cp16, feat_cp32 = self.cp(x)
        feat_sp = self.sp(x)
        feat_fuse = self.fam(feat_sp, feat_cp8)

        feat_out = self.conv_out(feat_fuse)
        if self.training:
            feat_out16 = self.conv_out16(feat_cp16)
            feat_out32 = self.conv_out32(feat_cp32)
            return feat_out, feat_out16, feat_out32
        # feat_out = feat_out.argmax(dim=1)
        return feat_out

这个网络训练的时候,进self.training的判断的时候,feat_cp16的大小是[4, 256, 32, 32],有256个通道。但是self.conv_out16定义的时候输出通道是128。feat_cp32的大小是[4, 512, 16, 16],有512个通道。但是self.conv_out16定义的时候输出通道还是128.(我网络进去的图的大小是[4, 3, 512, 512],是我哪操作不对吗?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions