MCPcopy Create free account
hub / github.com/d62lu/3DCTN / test

Function test

train_classification.py:51–77  ·  view source on GitHub ↗
(model, loader, num_class=40)

Source from the content-addressed store, hash-verified

49
50
51def test(model, loader, num_class=40):
52 mean_correct = []
53 class_acc = np.zeros((num_class, 3))
54 classifier = model.eval()
55
56 for j, (points, target) in tqdm(enumerate(loader), total=len(loader)):
57
58 if not args.use_cpu:
59 points, target = points.cuda(), target.cuda()
60
61 points = points.transpose(2, 1)
62 pred, _ = classifier(points)
63 pred_choice = pred.data.max(1)[1]
64
65 for cat in np.unique(target.cpu()):
66 classacc = pred_choice[target == cat].eq(target[target == cat].long().data).cpu().sum()
67 class_acc[cat, 0] += classacc.item() / float(points[target == cat].size()[0])
68 class_acc[cat, 1] += 1
69
70 correct = pred_choice.eq(target.long().data).cpu().sum()
71 mean_correct.append(correct.item() / float(points.size()[0]))
72
73 class_acc[:, 2] = class_acc[:, 0] / class_acc[:, 1]
74 class_acc = np.mean(class_acc[:, 2])
75 instance_acc = np.mean(mean_correct)
76
77 return instance_acc, class_acc
78
79
80def main(args):

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected