MCPcopy Create free account
hub / github.com/LAMDA-CL/CVPR22-Fact / count_acc_taskIL

Function count_acc_taskIL

utils.py:91–109  ·  view source on GitHub ↗
(logits, label,args)

Source from the content-addressed store, hash-verified

89 return float(topk/total)
90
91def count_acc_taskIL(logits, label,args):
92 basenum=args.base_class
93 incrementnum=(args.num_classes-args.base_class)/args.way
94 for i in range(len(label)):
95 currentlabel=label[i]
96 if currentlabel<basenum:
97 logits[i,basenum:]=-1e9
98 else:
99 space=int((currentlabel-basenum)/args.way)
100 low=basenum+space*args.way
101 high=low+args.way
102 logits[i,:low]=-1e9
103 logits[i,high:]=-1e9
104
105 pred = torch.argmax(logits, dim=1)
106 if torch.cuda.is_available():
107 return (pred == label).type(torch.cuda.FloatTensor).mean().item()
108 else:
109 return (pred == label).type(torch.FloatTensor).mean().item()
110
111def confmatrix(logits,label,filename):
112

Callers

nothing calls this directly

Calls 1

itemMethod · 0.80

Tested by

no test coverage detected