frompaddle.trainer.PyDataProvider2import*# Define a py data provider@provider(input_types=[dense_vector(28*28),integer_value(10)])defprocess(settings,filename):# settings is not used currently.imgf=filename+"-images-idx3-ubyte"labelf=filename+"-labels-idx1-ubyte"f=open(imgf,"rb")l=open(labelf,"rb")f.read(16)l.read(8)# Define number of samples for train/testif"train"infilename:n=60000else:n=10000foriinrange(n):label=ord(l.read(1))pixels=[]forjinrange(28*28):pixels.append(float(ord(f.read(1)))/255.0)yield{"pixel":pixels,'label':label}f.close()l.close()