# -*- encoding:utf-8 -*-
import numpy as np


def load_data(path='mnist.npz'):
    f = np.load(path)
    x_train, y_train = f['x_train'], f['y_train']
    x_test, y_test = f['x_test'], f['y_test']
    print(len(y_train))
    print(len(y_test))
    f.close()
    return (x_train, y_train), (x_test, y_test)


print("开始读取数据")
(train_X, train_y), (test_X, test_y) = load_data()
print("读取结束")

train_data=zip(train_X,train_y)
train_data=[str([x.tolist(),y]) for [x,y] in train_data]
test_data=zip(test_X,test_y)
test_data=[str([x.tolist(),y]) for [x,y] in test_data]
with open("train_data","w") as f:
	f.writelines("\n".join(train_data))
with open("test_data","w") as f:
	f.writelines("\n".join(test_data))
