icandle / CAMixerSR

CAMixerSR: Only Details Need More “Attention” (CVPR 2024)
https://arxiv.org/abs/2402.19289
Apache License 2.0
226 stars 13 forks source link

classsr #31

Open BONESWORD opened 1 month ago

BONESWORD commented 1 month ago

你好,感谢你们的 开源工作,在你们的代码中的classsr的模块中出现了一段引入,但是在你们的给出的路径下我并没有找到arch_util,在basicsr中是有arch_util的,注释是我添加的部分,不知道这是否是正确的表达形式

屏幕截图 2024-06-23 175832
icandle commented 1 month ago

是的,这一部分用到的部分应该是basicsr中的default_init_weights或者是ClassSR中的arch_util的initialize_weights,具体实现如下:

def initialize_weights(net_l, scale=1):
    if not isinstance(net_l, list):
        net_l = [net_l]
    for net in net_l:
        for m in net.modules():
            if isinstance(m, nn.Conv2d):
                init.kaiming_normal_(m.weight, a=0, mode='fan_in')
                m.weight.data *= scale  # for residual block
                if m.bias is not None:
                    m.bias.data.zero_()
            elif isinstance(m, nn.Linear):
                init.kaiming_normal_(m.weight, a=0, mode='fan_in')
                m.weight.data *= scale
                if m.bias is not None:
                    m.bias.data.zero_()
            elif isinstance(m, nn.BatchNorm2d):
                init.constant_(m.weight, 1)
                init.constant_(m.bias.data, 0.0)