SPM_toolkit icon indicating copy to clipboard operation
SPM_toolkit copied to clipboard

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

Open caoxu915683474 opened this issue 6 years ago • 3 comments

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 avatar Jun 25 '18 07:06 caoxu915683474

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

is this also ok ?

caoxu915683474 avatar Jun 25 '18 07:06 caoxu915683474

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.

lanwuwei avatar Jun 25 '18 15:06 lanwuwei

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

caoxu915683474 avatar Jun 27 '18 07:06 caoxu915683474