@@ -0,0 +1,973 @@
+#Dataset Helper%0A#%0A%0Aimport tflearn%0Aimport numpy as np%0A%0A# import tflearn.datasets.mnist as mnist%0A# X, Y, testX, testY = mnist.load_data(one_hot=True)%0A%0A#reshape a from 784x1 to 28x28%0A#a = a.reshape(28,28)%0A%0Adef label_of(one_hot_vector):%0A%09return one_hot_vector.argmax()%0A%0Adef small_set(X,Y,instances,classes):%0A%09instances_of_class = instances/classes%0A%09counter = np.zeros(classes)%0A%09#add one instance of one class to counter%0A%09index_list = %5B%5D%0A%09c = 0%0A%09while (np.sum(counter) %3C instances and c %3C len(X)):%0A%09%09label = label_of(Y%5Bc%5D)%0A%09%09if(counter%5Blabel%5D %3C instances_of_class):%0A%09%09%09counter%5Blabel%5D+=1%0A%09%09%09index_list.append(c)%0A%09%09c+=1%0A%09#prepare output%0A%09nX = %5B%5D%0A%09nY = %5B%5D%0A%09for i in index_list:%0A%09%09nX.append(X%5Bi%5D)%0A%09%09nY.append(Y%5Bi%5D)%0A%09return np.array(nX), np.array(nY)%0A%0Adef get_small_mnist(instances):%0A%09import tflearn.datasets.mnist as mnist%0A%09X, Y, testX, testY = mnist.load_data(one_hot=True)%0A%09x, y = small_set(X,Y,instances,10)%0A%09tx, ty = small_set(testX,testY,instances/10,10)%0A%09return x, y, tx, ty%0A%0A

add dataset helper -> small_set(); get_small_mnist()