import torch def accuracy(output, target, topk=(1,)): maxk = max(topk) # topk=(1,)取top1准确率,topk=(1,5)取top1和top5准确率 batch_size = target.size(0) _, pred = output.topk(maxk, 1, True, True) # topk参数中,maxk取得是top1准确率,dim=1是按行取值, largest=1是取最大...