Role of Choosing Correct Loss Function

Vishal Rajput
AIGuys
Published in
6 min readNov 27, 2021

--

Loss functions play a very important role in the training of modern Deep learning architecture, choosing the right loss function is the key to successful model building. A loss function is a mathematical equation that a deep learning architecture tries to minimize or optimize. Deep learning is an iterative process, in every step, it calculates some metric that tells the system how close its prediction is to the original label. Based on the calculated loss value, the network optimizes its parameters. There are a lot of loss functions and among those, the most popular ones are Mean square error, categorical cross-entropy, Dice loss, etc. If you want to read more about different loss functions go to the TensorFlow website https://www.tensorflow.org/api_docs/python/tf/keras/losses

Loss functions can be divided into two major categories: specialized loss functions and generalized loss functions. Generalized loss functions are those functions that can be used with almost any DL task like text prediction, image recognition, image classification, etc (Mean square error). Whereas specialized loss functions are designed for specific applications like semantic segmentation. Boundary loss and focal loss are good examples of specialized loss functions. Before we move further, here’s a question to you, why do loss functions behave differently? Why are certain losses good for a particular task and bad for others?

When I change the loss function, basically the optimization problem changes and that’s why we have different results. But…

--

--