16.03.2021 Views

Advanced Deep Learning with Keras

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Introducing Advanced Deep Learning with Keras

Train labels: {0: 5923, 1: 6742, 2: 5958, 3: 6131, 4: 5842, 5: 5421, 6:

5918, 7: 6265, 8: 5851, 9: 5949}

Test labels: {0: 980, 1: 1135, 2: 1032, 3: 1010, 4: 982, 5: 892, 6: 958,

7: 1028, 8: 974, 9: 1009}

Afterward, the code will plot 25 random digits as shown in the preceding figure,

Figure 1.3.1.

Before discussing the multilayer perceptron classifier model, it is essential to keep in

mind that while MNIST data are 2D tensors, they should be reshaped accordingly

depending on the type of input layer. The following figure shows how a 3 × 3

grayscale image is reshaped for MLPs, CNNs, and RNNs input layers:

Figure 1.3.2: An input image similar to the MNIST data is reshaped depending on the type of input layer.

For simplicity, reshaping of a 3 × 3 grayscale image is shown.

MNIST digits classifier model

The proposed MLP model shown in Figure 1.3.3 can be used for MNIST digit

classification. When the units or perceptrons are exposed, the MLP model is a fully

connected network as shown in Figure 1.3.4. It will also be shown how the output of

the perceptron is computed from inputs as a function of weights, w i

and bias, b n

for

the n th unit. The corresponding Keras implementation is illustrated in Listing 1.3.2.

[ 8 ]

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!