import numpy as np from sklearn.neural_network import MLPClassifier 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'] X_train = X_train.astype('float32') X_test = X_test.astype('float32') X_train /= 255. X_test /= 255. X_train = X_train.reshape(60000,784) X_test = X_test.reshape(10000,784) mlp = MLPClassifier(hidden_layer_sizes=(100,100,100)) mlp.fit(X_train,y_train) print('Training set score: %f' % mlp.score(X_train,y_train)) print('Test set score: %f' % mlp.score(X_test,y_test)) # print(X_train[0]) ''' print(X_train.shape) print(y_train.shape) print(X_test.shape) print(y_test.shape) '''