Loss Function

Loss Function



  • Also known as Energy Function

  • Used to evaluate a model based on some data and the ground truth loss_function_76fc65791123d1377d847ac44ee503999fc3967f.svg

  • This is used to optimize the model during training

  • Mathematically it is just defined as a Norm function, to evaluate the distance between the model and the ground truth.

  • Like the different kind of Norm functions, there are also different Loss functions (here the loss between indivisual data points and the prediction).

    • L1-Loss: loss_function_4fc13475ca98763519a7a21ed275d8016f7211b2.svg
    • L2-Loss: loss_function_aed1c72dbdc86a214c7859a4cc91536e0249abbd.svg
  • The loss function can also be computed for the whole model (all data points).

  • Normalized over the number of data points: the mean loss

    • L1-Loss : l1

      loss_function_e5e6a336b65ba32395f48467ea12f1aedfd0368a.svg
    • MSE-Loss: “Mean squared error”

      loss_function_27b24570e552f88ba5a17869b881bb69ec23252a.svg
    • Binary Cross Entropy Loss: Used in Logistic Regression .

      loss_function_9f3b80512e977391eb4dcdc660ab65a7eb8a0a3a.svg
    • General Cross Entropy Loss: for loss_function_4d6ca337e16d2a492fe2f0db9809d3c5367a9f62.svg different labels/classes

      loss_function_2a17671b1ba30d8d73f3c17b3eada20764b31f33.svg

Example #

We want to classify images using 3 labels: “Cat”, “Dog”, “Deer”. The neural network will output a vector OF the probabilities for each image. For a given image the network would for exampe output loss_function_7fe427d48f36fa79d17f3afac81c2e19f04ae7e8.svg this is then compared with the ground truth, so something like loss_function_bc1f3c77a12d1454850648ed19f04b87a64ab8f7.svg if the image was a cat. We can then compute the Loss-Function to measure how good/bad the prediction was.

loss_function_ea941f630a4306254fda5445396ae7052b63c66b.svg
Calendar October 22, 2023