Multiclass SVM loss function: Multiclass SVM loss

1. SVM loss: In one sample, the real classification for each category with each other, if the resulting real classification score with each other resulting classification score gap equal to or greater than the safe distance, without the loss of real classification tag value and the classification; otherwise you need to calculate the loss of the true classification and the classification; classification and the sum of the real value of each of the other loss is the loss of the value of the classification of a sample

① i.e. real label classification resulting score is greater than the safety distance equal score + classification, S_yi> = S_j + △, the value of loss = 0 then 

② Otherwise, the loss is equal to + safety distance score (threshold value) in another class - real label classification score obtained, i.e. the value of loss = S_j + △ - S_yi

S_yi: Score S_j real label classification: △ score another label: the safe distance threshold 

③ above are per one sample, a value of the loss = n samples arithmetic mean value of loss of Li + and regularization (Each sample refers to data for each test)

④ algorithmic process: For each sample, calculation of the loss of the true classification and the classification of each other, the sum of the actual loss values ​​with various other classification categories is the loss of the value of a sample;

The arithmetic mean of all samples and the value of loss = + regularization overall loss values

 

Li :( for understanding the safety distance) where a = 1

 

Li expression:

 

 

 

 

L expression:

 

 

 

2. Multiclass SVM loss of image: threshold 1

 

 

3. Examples

① classified a total of three real samples, the first sample of a cat, the second is the car, the third is the frog.

Note: Real label classification refers to the real data, rather than the predicted label

 

 

 

② the first sample, the label is a real cat, so if you want to calculate the score with a cat classification score in other classifications within a safe range

max (car + scores a safe distance - cat score, 0) + max (frog score + safety clearance - cat score, 0) = max (2.9, 0) + max (-3.9,0) = 2.9

The loss of all the first sample value of 2.9, and so on

 

 

 

③ After the calculated loss values ​​of three samples, three samples arithmetically mean values ​​and loss, the result is an overall loss values ​​(in fact generally also add a regularization)

 

 

 

4. Code

Guess you like

Origin www.cnblogs.com/shiliuxinya/p/12229676.html
svm