CH 02 Summary
CH 02 Summary
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 )
• 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.
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