mesnico / RelationNetworks-CLEVR

A pytorch implementation for "A simple neural network module for relational reasoning", working on the CLEVR dataset
MIT License
87 stars 26 forks source link

stack() fails #5

Open StrangeTcy opened 5 years ago

StrangeTcy commented 5 years ago

train.py fails on both training from scratch and using a pre-trained model with the following error:

File "/RelationNetworks-CLEVR/utils.py", line 120, in collate_samples question=torch.stack(padded_questions) TypeError: stack(): argument 'tensors' (position 1) must be tuple of Tensors, not Tensor

StrangeTcy commented 5 years ago

If you use a list of torch.LongTensor.zero_()s instead, it seems to work.

mesnico commented 5 years ago

I think this issue is related with pytorch version you're using. Have you installed dependencies from the requirements.txt inside a virtualenv as explained in README?

As of now, this code works with pytorch 0.3.1. In later versions torch.stack() takes a sequence of Tensors as argument, so, if you are using a newer version of pytorch, torch.stack(list(padded_questions)) should work. However, other things should be adjusted if you use another version. Hence, I encourage you to install version 0.3.1 inside a virtualenv.