Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

size mismatch #41

Open
Xelawk opened this issue Jun 4, 2024 · 1 comment
Open

size mismatch #41

Xelawk opened this issue Jun 4, 2024 · 1 comment

Comments

@Xelawk
Copy link

Xelawk commented Jun 4, 2024

RuntimeError: Error(s) in loading state_dict for SLBR:
size mismatch for shared_decoder.up_im_atts.0.conv.weight: copying a param with shape torch.Size([1, 1, 3]) from checkpoint, the shape in current model is torch.Size([1, 1, 256]).
size mismatch for shared_decoder.up_mask_atts.0.conv.weight: copying a param with shape torch.Size([1, 1, 3]) from checkpoint, the shape in current model is torch.Size([1, 1, 256]).
size mismatch for coarse_decoder.atts_bg.0.conv.weight: copying a param with shape torch.Size([1, 1, 3]) from checkpoint, the shape in current model is torch.Size([1, 1, 128]).
size mismatch for coarse_decoder.atts_bg.1.conv.weight: copying a param with shape torch.Size([1, 1, 3]) from checkpoint, the shape in current model is torch.Size([1, 1, 64]).
size mismatch for coarse_decoder.atts_bg.2.conv.weight: copying a param with shape torch.Size([1, 1, 3]) from checkpoint, the shape in current model is torch.Size([1, 1, 32]).
size mismatch for coarse_decoder.atts_mask.0.conv.weight: copying a param with shape torch.Size([1, 1, 3]) from checkpoint, the shape in current model is torch.Size([1, 1, 128]).
size mismatch for coarse_decoder.atts_mask.1.conv.weight: copying a param with shape torch.Size([1, 1, 3]) from checkpoint, the shape in current model is torch.Size([1, 1, 64]).
size mismatch for coarse_decoder.atts_mask.2.conv.weight: copying a param with shape torch.Size([1, 1, 3]) from checkpoint, the shape in current model is torch.Size([1, 1, 32]).

@Xelawk
Copy link
Author

Xelawk commented Jun 4, 2024

问题找到了,你的ECABlock有个channel的入参是无效的,导致我在重构后错误传给了k_size

class ECABlock(nn.Module):
    """Constructs a ECA module.

    Args:
        channel: Number of channels of the input feature map
        k_size: Adaptive selection of kernel size
    """
    def __init__(self, channel, k_size=3):
        super(ECABlock, self).__init__()
        self.avg_pool = nn.AdaptiveAvgPool2d(1)
        self.conv = nn.Conv1d(1, 1, kernel_size=k_size, padding=(k_size - 1) // 2, bias=False) 
        self.sigmoid = nn.Sigmoid()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant