examples: RuntimeError: invalid argument 2: size '[-1 x 300]' for SNLI example
I get the following error when I try to run the SNLI example on my machine.
Traceback (most recent call last):
File "train.py", line 35, in <module>
inputs.vocab.load_vectors(wv_dir=args.data_cache, wv_type=args.word_vectors, wv_dim=args.d_embed)
File "/usr/local/lib/python2.7/dist-packages/torchtext/vocab.py", line 162, in load_vectors
wv_dict, wv_arr, self.wv_size = load_word_vectors(wv_dir, wv_type, wv_dim)
File "/usr/local/lib/python2.7/dist-packages/torchtext/vocab.py", line 70, in load_word_vectors
wv_arr = torch.Tensor(wv_arr).view(-1, wv_size)
RuntimeError: invalid argument 2: size '[-1 x 300]' is invalid for input of with 544881656 elements at /pytorch/torch/lib/TH/THStorage.c:37
Not sure if this is an error in the way the vectors are being loaded, or an error in torchtext itself. I’m using Python 2.7.12 on Ubuntu 16.04.
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Comments: 15
Had kind of the same issue with the same error but my padding was correct. With my issue I was flattening incorrectly and was able to resolve by verifying the size of x before flattening the tensor and corrected my x.view and the fc1 layer accordingly.
I got the similar error, can you elaborate a little bit more on “You need to calculate the input size of this layer according to the input size of the net.”
I got the following error:
Full error information:
My code block:
Found the cause: “parameter padding=1” was missing in one layer.
Wrong code:
Right code: