Cat() got an unexpected keyword argument 'out'

t1 = Variable(torch.ones(2)) t2 = Variable(torch.zeros(2)) torch.stack([t1,t2],dim=1)
Run above code, and I recevied an error like this:

TypeError Traceback (most recent call last)
in ()
----> 1 torch.stack(t,1)

/users1/xwgeng/anaconda2/lib/python2.7/site-packages/torch/functional.pyc in stack(sequence, dim, out)
54 if dim < 0:
55 dim += sequence[0].dim()
—> 56 return torch.cat(list(t.unsqueeze(dim) for t in sequence), dim, out=out)
57
58

TypeError: cat() got an unexpected keyword argument ‘out’

And my pytorch version is 0.1.11+2b56711. It works before I update into the latest pytorch

1 Like

it seems something goes wrong with the latest commit, https://github.com/pytorch/pytorch/pull/1323 . but I’m not sure because I don’t know much about C/C++.

I would expect that error if you pull the latest Python code from GitHub master but don’t rebuild the C extension. If you’re building from source, make sure you rebuild the C extension:

python setup.py clean
python setup.py install

(or substitute “build develop” for “install”)

I do as you said. Now torch.cat works fine for tensor, but fails for variable. I think it’s because Concat function doesn’t have keyword out. Maybe it could be fixed by