How to optimize top5 accuracy instead of top1?

146 views
Skip to first unread message

Terry Chen

unread,
Jun 6, 2016, 3:25:15 PM6/6/16
to Caffe Users
As subject mentioned, most of loss functions optimize top-1 accuracy, if I don't care top-1 accuracy and wanna make top-5 accuracy higher, how to implement this? Thanks a lot.

Hossein Hasanpour

unread,
Jun 6, 2016, 4:56:50 PM6/6/16
to Caffe Users
If you dont care about top-1, then remove it and simply use the top 5 instead!

Terry Chen

unread,
Jun 6, 2016, 5:16:57 PM6/6/16
to Caffe Users
I think what you mentioned is accuracy layer parameter. I just wanna optimize top-5 prediction accuracy using softmax loss, while current softmax loss focus on the ground truth (top-1) optimization.

MiuMiu

unread,
Jun 7, 2016, 1:41:00 AM6/7/16
to Caffe Users
I think you have to define mathematically the loss function for your problem

let's say correct classification is 

1 2 3 4 5 6 , 

top 1: the lost function is -log(item1)


top 5: 12345

output =  1234 6 5 ,   here what is p(output) for your model? , The loss function is no longer  -negative log prob anymore,

Jan

unread,
Jun 9, 2016, 6:21:45 AM6/9/16
to Caffe Users
I don't think that what you want to is meaningful, resp. one probably cannot derive a meaningful loss function for that.

When you say "most of loss functions optimize top-1 accuracy" you actually mean that they penalize wrong predictions and by this gradually improve the probability of a correct prediction. This is something you have to do anyway (for both good top-1 and top-5 accuracies), since in your predictions you still want a fairly high posterior probability for the correct class. And as such it is actually the only meaningful optimization to do: increasing the posterior probability of the correct class.

Jan
Reply all
Reply to author
Forward
0 new messages