Module-4 4
Module-4 4
Learning
Different Scenarios
p-norms visualized
w2
p w2
1 0.5
For example, if w1 = 0.5 1.5 0.75
2 0.87
3 0.95
∞ 1
p-norms visualized
• The idea behind early stopping is that when we’re fitting a neural
network on the training data and model is evaluated on the unseen
data after each iteration. If the performance of the model on the
validation data is not improving i.e…validation error is increasing or
remaining the same for certain iterations, then there is no point in
training the model further. This process of stopping model training
before it reaches the lowest training error is known as early stopping.
Early Stopping
Here the value 0.01 is the value of regularization parameter, i.e., lambda, which we need to optimize
further.
We can optimize it using the grid-search method.
Code: Dropout
from keras.layers.core
import Dropout model = Sequential([ Dense(output_dim=hidden1_num_units,
input_dim=input_num_units, activation='relu'), Dropout(0.25),
Dense(output_dim=output_num_units, input_dim=hidden5_num_units,
activation='softmax'), ])
• Here, monitor denotes the quantity that needs to be monitored and ‘val_err’ denotes
the validation error.
• Patience denotes the number of epochs with no further improvement after which the
training will be stopped. For better understanding, let’s take a look at the above image
again. After the dotted line, each epoch will result in a higher value of validation error.
Therefore, 5 epochs after the dotted line (since our patience is equal to 5), our model
will stop because no further improvement is seen.