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

How to add an extra channel to the Restnet50 model architecture? #100

Closed
prakharsdev opened this issue Aug 4, 2022 · 1 comment
Closed

Comments

@prakharsdev
Copy link

TransUNet/networks/vit_seg_modeling_resnet_skip.py)

When I tried to add the 4th channel but it throws me this error:

RuntimeError: Given groups=1, weight of size [64, 3, 7, 7], expected input[2, 4, 256, 256] to have 3 channels, but got 4 channels instead

@prakharsdev
Copy link
Author

I got the solution to it. I just have to change 3 to 4 in:

`class ResNetV2(nn.Module):
"""Implementation of Pre-activation (v2) ResNet mode."""

def __init__(self, block_units, width_factor):
    super().__init__()
    width = int(64 * width_factor)
    self.width = width

    self.root = nn.Sequential(OrderedDict([
        ('conv', StdConv2d(4, width, kernel_size=7, stride=2, bias=False, padding=3)),
        ('gn', nn.GroupNorm(32, width, eps=1e-6)),
        ('relu', nn.ReLU(inplace=True)),
        # ('pool', nn.MaxPool2d(kernel_size=3, stride=2, padding=0))
    ]))`

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