gan3sh500 / local-relational-nets

A Pytorch implementation for the paper Local Relational Networks for Image Recognition (https://arxiv.org/pdf/1904.11491.pdf)
113 stars 21 forks source link

Error in test using a random image #5

Open ParadoxRobotics opened 4 years ago

ParadoxRobotics commented 4 years ago

Hi ! Thank you for your impressive implementation of the Local relation layer. I try to use it in a normal use case, but unfortunately your code doesn't work. I write the following code and parameters :

img = torch.randn(1, 3, 64, 64)
att_layer = LocalRelationalLayer(channels = 3, k = 1, stride = 1, m = 1, padding = 0)
y = att_layer(img)

but I get following error for the ending line :

File "Deep_Compositional_Networks.py", line 99, in forward
pre_output = (ck * x_unfold).view(x.shape[0], x.shape[1], -1, x_unfold.shape[-2] // x.shape[1])
RuntimeError: shape '[1, 3, -1, 1365]' is invalid for input of size 12288

If you have any idea why this configuration raise this error...?

Thank in advance for your help !

Junjue-Wang commented 2 years ago

You can refer to this example: https://github.com/gan3sh500/local-relational-nets/pull/7#issue-1071771497