July 2019
Intermediate to advanced
512 pages
19h 39m
English
Now, we will see how we can perform MNIST handwritten digit classification, using TensorFlow 2.0. It requires only a few lines of code compared to TensorFlow 1.x. As we have learned, TensorFlow 2.0 uses Keras as its high-level API; we just need to add tf.keras to the Keras code.
Let's start by loading the dataset:
mnist = tf.keras.datasets.mnist
Create a train and test set with the following code:
(x_train,y_train), (x_test, y_test) = mnist.load_data()
Normalize the train and test sets by dividing the values of x by the maximum value of x; that is, 255.0:
x_train, x_test = tf.cast(x_train/255.0, tf.float32), tf.cast(x_test/255.0, tf.float32)y_train, y_test = tf.cast(y_train,tf.int64),tf.cast(y_test,tf.int64) ...
Read now
Unlock full access