lanwuwei / SPM_toolkit

Neural network toolkit for sentence pair modeling.
303 stars 70 forks source link

cat(): argument 'tensors' (position 1) must be tuple of Tensors, not generator #4

Open caoxu915683474 opened 6 years ago

caoxu915683474 commented 6 years ago

https://github.com/lanwuwei/SPM_toolkit/blob/3e2cb35681e9f31bfcc66afde2159bbf394056df/DecAtt/main_quora.py#L56

cat(): argument 'tensors' (position 1) must be tuple of Tensors, not generator

can I fix this bug use this line?

torch.cat(tuple([dict[word].view(1, -1) for word in lsent]))

caoxu915683474 commented 6 years ago

torch.cat([dict[word].view(1, -1) for word in lsent])

is this also ok ?

lanwuwei commented 6 years ago

Hi caoxu, I tried your second answer in other code: https://github.com/lanwuwei/Subword-PWIM/blob/6e9ef11fa404c4ea6e350f8e75f7d1055869d8d9/model.py#L436 In my PyTorch version 0.4.0, both are OK. You can modify the code based on your version.

caoxu915683474 commented 6 years ago

@lanwuwei Thanks for your help, I find my pytorch version is not 0.4.0.