问题
使用TEXT.build_vocab时报错Fan in and fan out can not be computed for tensor with fewer than 2 dimensions
vectors.unk_init = init.xavier_uniform_ # 没有命中的token的初始化方式
TEXT.build_vocab(train, min_freq=5, vectors=vectors)
原因是torchtext版本太高,不支持一维的词向量,仅仅支持二维以上的
解决
(1)方法一
是torchtext的版本问题,更换torchtext版本为0.2.3 问题解决
pip install torchtext==0.2.3