09.05.2023 Views

pdfcoffee

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

Neural Network Foundations with TensorFlow 2.0

We can use a hyperparameter λλ >=0 for controlling the importance of having a simple

model, as in this formula:

min: {loss(Training Data|Model)} + λλ * complexity(Model)

There are three different types of regularization used in machine learning:

• L1 regularization (also known as LASSO): The complexity of the model

is expressed as the sum of the absolute values of the weights.

• L2 regularization (also known as Ridge): The complexity of the model

is expressed as the sum of the squares of the weights

• Elastic regularization: The complexity of the model is captured by

a combination of the preceding two techniques

Note that playing with regularization can be a good way to increase the performance

of a network, particularly when there is an evident situation of overfitting. This set

of experiments is left as an exercise for the interested reader.

Also note that TensorFlow supports L1, L2, and ElasticNet regularization. Adding

regularization is easy:

from tf.keras.regularizers import l2, activity_l2

model.add(Dense(64, input_dim=64, W_regularizer=l2(0.01),

activity_regularizer=activity_l2(0.01)))

A complete list of regularizers can be found at https://

www.tensorflow.org/api_docs/python/tf/keras/

regularizers.

Understanding BatchNormalization

BatchNormalization is another form of regularization and one of the most effective

improvements proposed during the last few years. BatchNormalization enables us to

accelerate training, in some cases by halving the training epochs, and it offers some

regularization. Let's see what the intuition is behind it.

[ 38 ]

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

Saved successfully!

Ooh no, something went wrong!