您的位置:首页 > 理论基础 > 计算机网络

神经网络与深度学习第一章问题(Python2.x转到python3.x)

2017-12-30 19:19 477 查看
今天看《Neural Networks and Deep Learning》的神经网络程序,源程序为python2.x,采用python3.6时会遇到一些错误:

转自http://blog.csdn.net/taotaoking/article/details/78583448

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、SGD函数中zip出错,改为:
     test_data=list(test_data)
     n_test = len(test_data)# the number of testing samples

     

     training_data = list(taining_data)
      先转化为list然后再len

 activation = self.sigmoid(z)

TypeError: sigmoid() takes 1 positional argument but 2 were given(其实包含了一个object参数隐藏)

应改为sigmoid(self,z),这样传入的默认object参数才能接收
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: