Torch.cat() returning None. (Solved by pytorch reinstallation)

I’ve been using torch.cat() for my unet implementation, but in pytorch 0.4.0 it has begun to return None and is defined as such:

def cat(param, dim):
return None

in torch’s init.py for me. How would I go about fixing this? I tried to use torch.stack() but it expects tensors to have the same shape. I’m getting this error:

RuntimeError: invalid argument 0: Sizes of tensors must match except in dimension 1. Got 512 and 256 in dimension 2 at c:\programdata\miniconda3\conda-bld\pytorch_1524549877902\work\aten\src\th\generic/THTensorMath.c:3586

from this line:

x = torch.stack((x, prev_feature_map), dim=1)

Hope to hear from you soon! And thank you in advance!

Could you tell me, where you have found the init.py defining cat?
Also, could you try to run the following code:

a = torch.randn(10, 2)
b = torch.randn(2, 2)

c = torch.cat((a, b), dim=0)

and post the result?

1 Like

I’m getting this back:
image

Thank you for reply, ptrblck!
Oh, and sorry about the delay. I was out helping my father cut down some trees for the garage he’s building.
I’m gonna try reinstalling pytorch. Will be back with results.

Reinstalling pytorch seems to have fixed the issue. Sorry about creating the thread! I was just really confused.

No worries. It was a weird bug.
Did you build PyTorch from source or installed the binaries?

Sure was… Anyway, thank you for your quick reply! Thought I might’ve updated the library and that they had renamed it or something first. I use conda to install it. Bit easier since I’m on windows 10 at the moment.