How does one use tnt.meter.ConfusionMeter? It would be good if a snippet is available.
just used it a few minutes ago in a classifier network
confusion_matrix = meter.ConfusionMeter(2) #I have 2 classes here
for ii, data in enumerate(val_dataloader):
input, label = data
val_input = Variable(input, volatile=True).cuda()
val_label = Variable(label.type(t.LongTensor), volatile=True).cuda()
score = model(val_input)
confusion_matrix.add(score.data.squeeze(), label.type(t.LongTensor))
print confusion_matrix.conf
got something like:
[[1152, 434],
[764, 722]]
that is
[true negative, false postive]
[false negative,ture postive]
6 Likes
Thank you. I figured that I had to convert the Autograd Variable
back into a tensor for ConfusionMeter
to do the .numpy()
conversion to get it to work properly.
score and label are Autograd variables so
Confusion_matrix.add(score.data, label.data) will work