def shared_mnist():
def shared_dataset(data_xy):
data_x, data_y = data_xy
np_y = np.zeros((len(data_y), 10), dtype=theano.config.floatX)
for i in xrange(len(data_y)):
np_y[i, data_y[i]] = 1
shared_x = theano.shared(np.asmatrix(data_x, dtype=theano.config.floatX))
shared_y = theano.shared(np.asmatrix(np_y, dtype=theano.config.floatX))
return shared_x, shared_y
f = gzip.open(curr_path + "/data/mnist.pkl.gz", "rb")
train_set, valid_set, test_set = cPickle.load(f)
f.close()
test_set_x, test_set_y = shared_dataset(test_set)
valid_set_x, valid_set_y = shared_dataset(valid_set)
train_set_x, train_set_y = shared_dataset(train_set)
return [train_set_x, train_set_y], [valid_set_x, valid_set_y], [test_set_x, test_set_y]
data.py 文件源码
python
阅读 25
收藏 0
点赞 0
评论 0
评论列表
文章目录