lancopku/SGM

运行preprocess.py时出错

hanyegirl opened this issue · 2 comments

[dhy@mu01 SGM-master]$ python preprocess.py
Building source vocabulary...
max: 64, min: 1, avg: 5.17
Traceback (most recent call last):
File "preprocess.py", line 261, in
main()
File "preprocess.py", line 234, in main
opt.src_vocab_size)
File "preprocess.py", line 118, in initVocabulary
genWordVocab = makeVocabulary(dataFile, vocabSize, char=char)
File "preprocess.py", line 99, in makeVocabulary
vocab = vocab.prune(size)
File "/home/dhy/multi_label/SGM-master/data/dict.py", line 123, in prune
newDict.add(self.idxToLabel[i])
KeyError: tensor(46)
这是什么原因呢

cause the key should be an integer, you can fix the error by changing this line into newDict.add(self.idxToLabel[i.item()]).

Or change your version of torch to 0.3.1