lemniscate.pytorch icon indicating copy to clipboard operation
lemniscate.pytorch copied to clipboard

RuntimeError: set_sizes_contiguous is not allowed on Tensor created from .data or .detach(), in Pytorch 1.1.0

Open HHHedo opened this issue 5 years ago • 3 comments

My pytorch is 1.1.0. x.data.resize(batchSize, inputSize, 1)_ in NCEAverage.py doesn't work. with torch.no_grad(): x.resize(batchSize, inputSize, 1)_ still doesn't work. I replaced it as _ x.unsqueeze(2))_ . I wonder if this function works the same as x.data.resize(batchSize, inputSize, 1)_

HHHedo avatar Aug 01 '19 08:08 HHHedo

Hi, there. Have you solved the compatibility of Pytorch?

ChongjianGE avatar Dec 07 '19 08:12 ChongjianGE

Use torch.reshape out = torch.bmm(weight, torch.reshape(x, (batchSize, inputSize, 1)))

robert780612 avatar Dec 19 '19 11:12 robert780612

It seems that robert's suggestions can work, but gradOutput.data.resize_(batchSize, 1, K+1) in around line 60 should be changed to gradOutput.resize_(batchSize, 1, K + 1).

Crestina2001 avatar Apr 07 '23 14:04 Crestina2001