(10条消息) 文本分类系列(1):textcnn及其pytorch实现_u014514939的博客-CSDN博客
问题1:UnicodeDecodeError: 'gbk' codec can't decode byte 0x80 in position 111: illegal multibyte sequence
解决方法:python打开文本,改变文件的编码方式在
file_object = open('data/stopwords.txt',encoding='utf-8')添加encoding='utf-8'
问题2:
AttributeError: module 'torchtext.data' has no attribute 'Field'
解决方法:将 from torchtext import data 改为from torchtext.legacy import
问题3:RuntimeError: set_storage_offset is not allowed on a Tensor created from .data or .detach().
解决方法:将
feature.data.t_(), target.data.sub_(1)改为
feature = feature.data.t() target = target.data.sub(1)