Number identification using Multilayer Perceptrons
import tensorflow as tf from tensorflow.keras.datasets import mnist from tensorflow.keras.models import Sequential from tensorflow.keras.layers import Dense, Flatten (x_train, y_train), (x_test, y_test) = mnist.load_data() x_train = x_train.reshape( 60000 , 784 ).astype( 'float32' ) / 255 x_test = x_test.reshape( 10000 , 784 ).astype( 'float32' ) / 255 y_train = tf.keras.utils.to_categorical(y_train, 10 ) y_test = tf.keras.utils.to_categorical(y_test, 10 ) model = Sequential() model.add(Dense( 128 , activation= 'relu' , input_shape=( 784 ,))) model.add(Dense( 64 , activation= 'relu' )) model.add(Dense( 10 , activation= 'softmax' )) model. compile (optimizer= 'adam' , loss= 'categorical_crossentropy' , metrics=[ 'accuracy' ]) model.fit(x_train, y_train, epochs= 10 , batch_size= 128 , validation_data=(x_test, y_test)) test_loss, test_acc = model.evaluate(x_test, y_test) print ( 'Test accuracy:' , test_acc) ==...