Skip to content
PostDeep Learning / 00-Basic

Loss Function

2024-08-25
Back to Blog

#DeepLearning #LossFunction

Loss Function

Mean Squared Error (MSE):

MSE=1ni=1n(yiy^i)2
  • Used for regression tasks. Measures the average squared difference between actual values yi and predicted values y^i.

Mean Absolute Error (MAE):

MAE=1ni=1n|yiy^i|
  • Also used for regression tasks. It measures the average absolute difference between actual and predicted values.

Cross-Entropy Loss (Log Loss):

Cross-Entropy=1ni=1n[yilog(y^i)+(1yi)log(1y^i)]
  • 通常用于处理分类问题

    • n 即为分类总数
    • yi 即为真实类别概率
    • y^i 即为对该类别的预测概率
  • 通常, yi=1, 因为真实值是确定的,可化简得到

Cross-Entropy=1ni=1n[log(y^i)]

[!flex]

The derivative of cross entropy

Hinge Loss:

Hinge Loss=1ni=1nmax(0,1yiy^i)
  • Typically used for "maximum-margin" classifiers like Support Vector Machines (SVM).

Huber Loss:

Lδ(a)={12a2for |a|δ,δ(|a|12δ)otherwise.
  • A loss function used in regression that is less sensitive to outliers than MSE.

Kullback-Leibler (KL) Divergence:

DKL(PQ)=iP(i)log(P(i)Q(i))
  • Measures how one probability distribution P diverges from a second probability distribution Q. Often used in variational inference or generative models.

Negative Log-Likelihood Loss (NLL):

NLL=i=1nyilog(y^i)
  • Used for classification problems, particularly in models like neural networks with a softmax output.