torch / optim

A numeric optimization package for Torch.
Other
197 stars 154 forks source link

How to get top-5 or top-3 accuracy by ConfusionMatrix? #140

Open arashno opened 8 years ago

arashno commented 8 years ago

Hello all, Can I use ConfusionMatrix to compute top-n accuracy for my classifier or not? If yes, how can I do that? Is there any sample code to do that? Thanks

taineleau-zz commented 8 years ago

hi,

I think you need to hack the ConfusionMatrix.lua file if you want to get the top-k acc.

And there're two ways to calculate top-k acc., hope the following helps.

  1. please kindly check the resnet training script L107.
  2. Torchnet's utils for topk.