报错代码:
270it [00:00, 17380.78it/s]<torchtext.vocab.Vectors object at 0x7f80a89e4cf8>
read data from /home/lxy/new20g_disk/3a_research/pytorch_learning/util/word/train_set.csv
Traceback (most recent call last):
File "", line 1, in
runfile('/home/lxy/new20g_disk/3a_research/pytorch_Test/vectors.py', wdir='/home/lxy/new20g_disk/3a_research/pytorch_Test')
File "/home/lxy/anaconda3/lib/python3.5/site-packages/spyder/utils/site/sitecustomize.py", line 866, in runfile
execfile(filename, namespace)
File "/home/lxy/anaconda3/lib/python3.5/site-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "/home/lxy/new20g_disk/3a_research/pytorch_Test/vectors.py", line 79, in
TEXT.build_vocab(train, vectors=vectors)
File "/home/lxy/anaconda3/lib/python3.5/site-packages/torchtext/data/field.py", line 273, in build_vocab
self.vocab = self.vocab_cls(counter, specials=specials, **kwargs)
File "/home/lxy/anaconda3/lib/python3.5/site-packages/torchtext/vocab.py", line 88, in init
self.load_vectors(vectors, unk_init=unk_init, cache=vectors_cache)
File "/home/lxy/anaconda3/lib/python3.5/site-packages/torchtext/vocab.py", line 159, in load_vectors
self.vectors[i][start_dim:end_dim] = v[token.strip()]
File "/home/lxy/anaconda3/lib/python3.5/site-packages/torchtext/vocab.py", line 286, in getitem
return self.unk_init(torch.Tensor(self.dim))
File "/home/lxy/anaconda3/lib/python3.5/site-packages/torch/nn/init.py", line 218, in xavieruniform
fan_in, fan_out = _calculate_fan_in_and_fan_out(tensor)
File "/home/lxy/anaconda3/lib/python3.5/site-packages/torch/nn/init.py", line 181, in _calculate_fan_in_and_fan_out
raise ValueError("Fan in and fan out can not be computed for tensor with less than 2 dimensions")
ValueError: Fan in and fan out can not be computed for tensor with less than 2 dimensions
请问这个是什么原因啊,在TEXT.build_vocab(train, vectors=vectors)这一句报错了。 我看了下vectors的格式也正确,pytorch0.4.1版本。暂时不知道解决办法,求问,谢谢。
找到https://github.com/ShuangXieIrene/ssds.pytorch/issues/9 ,但并没有解决问题。
报错代码: 270it [00:00, 17380.78it/s]<torchtext.vocab.Vectors object at 0x7f80a89e4cf8> read data from /home/lxy/new20g_disk/3a_research/pytorch_learning/util/word/train_set.csv
Traceback (most recent call last):
File "", line 1, in
runfile('/home/lxy/new20g_disk/3a_research/pytorch_Test/vectors.py', wdir='/home/lxy/new20g_disk/3a_research/pytorch_Test')
File "/home/lxy/anaconda3/lib/python3.5/site-packages/spyder/utils/site/sitecustomize.py", line 866, in runfile execfile(filename, namespace)
File "/home/lxy/anaconda3/lib/python3.5/site-packages/spyder/utils/site/sitecustomize.py", line 102, in execfile exec(compile(f.read(), filename, 'exec'), namespace)
File "/home/lxy/new20g_disk/3a_research/pytorch_Test/vectors.py", line 79, in
TEXT.build_vocab(train, vectors=vectors)
File "/home/lxy/anaconda3/lib/python3.5/site-packages/torchtext/data/field.py", line 273, in build_vocab self.vocab = self.vocab_cls(counter, specials=specials, **kwargs)
File "/home/lxy/anaconda3/lib/python3.5/site-packages/torchtext/vocab.py", line 88, in init self.load_vectors(vectors, unk_init=unk_init, cache=vectors_cache)
File "/home/lxy/anaconda3/lib/python3.5/site-packages/torchtext/vocab.py", line 159, in load_vectors self.vectors[i][start_dim:end_dim] = v[token.strip()]
File "/home/lxy/anaconda3/lib/python3.5/site-packages/torchtext/vocab.py", line 286, in getitem return self.unk_init(torch.Tensor(self.dim))
File "/home/lxy/anaconda3/lib/python3.5/site-packages/torch/nn/init.py", line 218, in xavieruniform fan_in, fan_out = _calculate_fan_in_and_fan_out(tensor)
File "/home/lxy/anaconda3/lib/python3.5/site-packages/torch/nn/init.py", line 181, in _calculate_fan_in_and_fan_out raise ValueError("Fan in and fan out can not be computed for tensor with less than 2 dimensions")
ValueError: Fan in and fan out can not be computed for tensor with less than 2 dimensions