1.使用的tensorflow和python版本不一致,参考此博主和此博主将导入改为
import os
import numpy as np
#import tensorflow as tf
import tensorflow.compat.v1 as tf
tf.compat.v1.disable_eager_execution()
#import cPickle
import pickle as pickle
2.使用print时出错 SyntaxError: Missing parentheses in call to ‘print‘ Did you mean print(““),也是由于python版本不一致,于是将有打印的地方加上()
3.python 3以上版本使用pickle.load读取文件报UnicodeDecodeError: ‘ascii’ codec can’t decode byte 0x8b in position 6,改为
#dict = cPickle.load(fo)
dict = pickle.load(fo,encoding='iso-8859-1')
4.python 出现的问题:TypeError: ‘float’ object cannot be interpreted as an integer,还是python版本不一致问题
python2的规则中,“/”是取整,是int型
而在python3中,“/”符号是保留小数的,是float型
解决:改为“//” 即可