Top k error calculation

That line returns both values and indexes. Do pred=outputs.topk(5,1,largest=True,sorted=True)[0] to only get the values (although I haven’t looked at your code)