神经网络与深度学习第一章问题(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参数才能接收
转自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参数才能接收
相关文章推荐
- 深度学习中常见的python问题(1)
- 神经网络与深度学习第一章实验
- Python3读取深度学习CIFAR-10数据集出现的若干问题解决
- 神经网络与深度学习笔记(三)python 实现反向传播算法
- 深度学习中常见的python问题(1)
- 深度学习python库安装经验,Windows下安装Anaconda3 pycharm tensorflow keras theano中遇到的问题
- 深度学习中遇到的Python问题(三)
- 深度学习中遇到的Python问题(四)
- 深度学习中遇到的Python问题(二)
- python django学习-问题记录及解决方法
- 学习python处理python编码问题
- Python学习笔记(二)--解决中文的问题
- Python学习的小问题1(SyntaxError: Non-ASCII character)
- Python学习中遇到的问题(更新中...)
- python初级学习小问题
- python2.X编码问题梳理
- 学习python处理python编码问题
- 学习Python遇到的第一个问题:Python编辑器---Editra的配置
- python学习笔记:二维数组排序问题
- 关于新手学习python的常犯的基本问题