0% found this document useful (0 votes)
9 views

CH 02 Summary

Uploaded by

shahmurrawat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views

CH 02 Summary

Uploaded by

shahmurrawat
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

Ch: 02 Summary

(train_images, train_labels), (test_images, test_labels) = mnist.load_data()

train_images and train_labels form the training set, the data that the model will
learn from. The model will then be tested on the test set (test_images and
test_labels)

network = models.Sequential()

A Sequential model is appropriate for a plain stack of layers where each layer
has exactly one input tensor and one output tensor. Tensors are multi-
dimensional arrays

Syntax:
layers.Dense(no. of output generated at each layer, activation function,
input array )

network.add(layers.Dense(512, activation='relu', input_shape=(28 * 28,)))


network.add(layers.Dense(10, activation='softmax'))

• The core building block of neural networks is the layer, a data-processing


module that you can think of as a filter for data. Some data goes in, and it
comes out in a more useful form.

• Most of deep learning consists of chaining together simple layers that will
implement a form of progressive data distillation / filtering.

• Here, our network consists of a sequence of two Dense layers, which are
densely or fully connected neural layers. The second (and last) layer is a
10-way softmax layer, which means it will return an array of 10 probability
scores (summing to 1). Each score will be the probability that the current
digit image belongs to one of our 10-digit classes.
• ReLU Activation Function: The Rectified Linear Unit (ReLU) is a popular
activation function predominantly used in deep learning models. The
function outputs a value that is directly proportional to the input, which
makes it a simple yet effective utility for neural networks.

• Softmax Activation Function: The softmax function is often used as the


last activation function of a neural network to normalize the output of a
network

To make the network ready for training, we need to pick three more things, as
part of the compilation step:
A loss function—How the network will be able to measure its performance on
the training data, and thus how it will be able to steer itself in the right direction.
An optimizer—The mechanism through which the network will update itself
based on the data it sees and its loss function.
Metrics to monitor during training and testing—Here, we’ll only care about
accuracy (the images that were correctly classified).
network.compile(optimizer='rmsprop', loss='categorical_crossentropy',
metrics=['accuracy'])

We’re now ready to train the network, which in Keras is done via a call to the
network’s fit method—we fit the model to its training data:
network.fit(train_images, train_labels, epochs=5, batch_size=128)

(An epoch in machine learning means one complete pass of the training dataset
through the algorithm.)
Output: ETA: 1s - loss: 0.1035 - acc: 0.9892

test_loss, test_acc = network.evaluate(test_images, test_labels)


output: test_acc: 0.9785
We quickly reach an accuracy of 0.989 (98.9%) on the training data. The test-
set accuracy turns out to be 97.8%—that’s quite a bit lower than the training set
accuracy. This gap between training accuracy and test accuracy is an example of
overfitting: the fact that machine-learning models tend to perform worse on
new data than on their training data.

You might also like