今天看《Neural Networks and Deep Learning》的神经网络程序,源程序为python2.x,采用python3.6时会遇到一些错误:
1、xrange ->range python3.6中已经没有xrange
2、在load minist数据库时会报错:
UnicodeDecodeError: 'ascii' codec can't decode byte
可改为如下:
with gzip.open('../data/mnist.pkl.gz', 'rb') as f:
training_data, validation_data, test_data = pickle.load(f,encoding='latin1')#特别注意后面的encoding='latin1'
3、import pickle 后面也改为pickle
4、zip函数出错,改为:
test_data=list(test_data)
n_test = len(test_data)# the number of testing samples
先转化为list然后再len