发布网友 发布时间:2022-04-21 09:55
共2个回答
热心网友 时间:2023-11-09 03:20
studen=('xzj','jzx','zxj','jxz'),
这一句中最后的逗号去掉
不去掉的话就相当于studen=(('xzj','jzx','zxj','jxz'),)
这样studen就是含有两个元素的tuple,new_studen[0][3]相当于studen[3],所以就超出范围了
热心网友 时间:2023-11-09 03:21
trainlabfile.read(8)
trainlabels = zeros(60000)
line = trainlabfile.read(60000)
for i in range(60000):
trainlabels[i] = int(struct.unpack('B', line[i])[0])
testlabfile.read(8)
testlabels = zeros(10000)
line = testlabfile.read(10000)
for i in range(10000):
testlabels[i] = int(struct.unpack('B', line[i])[0])
data = dict()
data['testlabels'] = testlabels
data['trainlabels'] = trainlabels
data['testimages'] = testimages
data['trainimages'] = trainimages
cPickle.mp(data, open('mnist.p', 'w'), protocol=2)