遇见bug的尝试解决合集
1.Your CPU supports instructions that this TensorFlow binary was not compiled to use: SSE4.1 SSE4.2 AVX AVX2 FMA
import os os.environ["TF_CPP_MIN_LOG_LEVEL"]='1' # 这是默认的显示等级,显示所有信息 os.environ["TF_CPP_MIN_LOG_LEVEL"]='2' # 只显示 warning 和 Error os.environ["TF_CPP_MIN_LOG_LEVEL"]='3' # 只显示 Error
tf默认是在GPU上开发的,CPU中存在的一些指令集如AVX不能为tf所用。
2.Device mapping: no known devices.
尝试重新安装gpu版本
3.读取词向量文件编码问题
在读取pku50维词向量文件时,使用with codecs.open('news_tensite.w2v200','r','utf-8') as f: 读取会出现:
UnicodeDecodeError: 'utf8' codec can't decode bytes in position 9-10: invalid continuation
with codecs.open('news_tensite.w2v200','r') as f:
import codecs import numpy as np with codecs.open('news_tensite.pku.words.w2v50','r','utf-8') as f: d={} for line in f: l=line.split() d[l[0]]=np.array(map(float,l[1:])) print len(d)
file -i news_tensite.pku.words.w2v50
news_tensite.pku.words.w2v50: text/plain; charset=utf-8
//不明白。
另外出现了:UnicodeEncodeError: 'decimal' codec can't encode characters in position 0-2: invalid decimal Unicode string。
设置判断条件: if len(l)==51: 即可。