Last active
August 29, 2015 14:28
-
-
Save tnarihi/9d807c993d7f30d112bf to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
from sklearn.metrics import confusion_matrix | |
preds = () | |
labels = () | |
n_samples = ... number of examples in test set ... | |
batch_size = ... batch size ... | |
net = ... caffe test net ... | |
n_batch = int(np.ceil(n_samples / batch_size)) | |
for i in range(n_batch): | |
net.forward() | |
score, label = net.blobs['fc8'], net.blobs['label'] | |
pred = score.argmax(axis=1) | |
preds += pred, | |
labels ++ label, | |
preds = np.vstack(preds)[:n_samples] | |
labels = np.vstack(labels)[:n_samples] | |
cm = confusion_matrix(labels.flatten(), preds.flatten()) | |
plt.figure() | |
plt.imshow(cm, interpolation='nearest', cmap=plt.jet) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment