thomasjpfan / pytorch_refinenet

Pytorch Implementation of Refinenet
MIT License
160 stars 33 forks source link

number of channel mismatch #5

Open 1973Blunt opened 6 years ago

1973Blunt commented 6 years ago

Hi, thanks for sharing!

When I run the code:

net = RefineNet4Cascade((3, 224), num_classes=10)
opt = optim.Adam(net.parameters())
x = torch.randn(1, 3, 224, 224)
y = net(x)

I encountered the error: RuntimeError: Given groups=1, weight of size [256, 256, 3, 3], expected input[1, 512, 7, 7] to have 256 channels, but got 512 channels instead

with torch (0.4.1)

And when the channel in input_shape is not equal to 3, it occurs error too. I think it's because the in_channels of resnet.conv1 is not modified with input_shape.

thomasjpfan commented 6 years ago
  1. I am unable to reproduce the first issue with your example.

  2. The channels has to be 3 because the resnet backbone expects an input with 3 color channels.

1973Blunt commented 6 years ago

Thank you for the quick reply. I think I found the reason. My python is 3.5, which doesn't support string prefixed with 'f'. I straightforward deleted all 'f'. It works when 'f' is replaced by old string-format in 3.5,

thomasjpfan commented 6 years ago

Ah I see, I will update the strings to a more backward compatible style. (Python sure has many ways to do string formatting) 😅