Skip to content

Instantly share code, notes, and snippets.

@szagoruyko
Last active February 24, 2016 14:33
Show Gist options
  • Save szagoruyko/7f3728c180e02289edcc to your computer and use it in GitHub Desktop.
Save szagoruyko/7f3728c180e02289edcc to your computer and use it in GitHub Desktop.
require 'loadcaffe'
require 'optim'
local matio = require 'matio'
local dataset = torch.load('/opt/datasets/tiny-datasets/cifar10_whitened.t7')
local net = loadcaffe.load('/tmp/e56253735ef32c3c296d/train_val.prototxt','./cifar10_nin.caffemodel')
net:evaluate()
print(net)
local test_data = dataset.testData
local bs = 250
local confusion_matrix = optim.ConfusionMatrix(10)
for i=1,test_data:size(),bs do
local inputs = test_data.data:narrow(1,i,bs)
local targets = test_data.labels:narrow(1,i,bs)
local outputs = net(inputs):squeeze()
confusion_matrix:batchAdd(outputs, targets)
end
matio.save('cifar10_testData_whitened.mat', {data = test_data.data, labels = test_data.labels})
print(confusion_matrix)
@szagoruyko
Copy link
Author

Successfully loaded ./cifar10_nin.caffemodel
MODULE cifar UNDEFINED
warning: module 'cifar [type 5]' not found
conv1: 192 3 5 5
cccp1: 160 192 1 1
cccp2: 96 160 1 1
conv2: 192 96 5 5
cccp3: 192 192 1 1
cccp4: 192 192 1 1
conv3: 192 192 3 3
cccp5: 192 192 1 1
cccp6: 10 192 1 1
nn.Sequential {
  [input -> (1) -> (2) -> (3) -> (4) -> (5) -> (6) -> (7) -> (8) -> (9) -> (10) -> (11) -> (12) -> (13) -> (14) -> (15) -> (16) -> (17) -> (18) -> (19) -> (20) -> (21) -> (22) -> (23) -> (24) -> output]
  (1): cudnn.SpatialConvolution(3 -> 192, 5x5, 1,1, 2,2)
  (2): cudnn.ReLU
  (3): cudnn.SpatialConvolution(192 -> 160, 1x1)
  (4): cudnn.ReLU
  (5): cudnn.SpatialConvolution(160 -> 96, 1x1)
  (6): cudnn.ReLU
  (7): cudnn.SpatialMaxPooling(3,3,2,2)
  (8): nn.Dropout(0.500000)
  (9): cudnn.SpatialConvolution(96 -> 192, 5x5, 1,1, 2,2)
  (10): cudnn.ReLU
  (11): cudnn.SpatialConvolution(192 -> 192, 1x1)
  (12): cudnn.ReLU
  (13): cudnn.SpatialConvolution(192 -> 192, 1x1)
  (14): cudnn.ReLU
  (15): cudnn.SpatialAveragePooling(3,3,2,2)
  (16): nn.Dropout(0.500000)
  (17): cudnn.SpatialConvolution(192 -> 192, 3x3, 1,1, 1,1)
  (18): cudnn.ReLU
  (19): cudnn.SpatialConvolution(192 -> 192, 1x1)
  (20): cudnn.ReLU
  (21): cudnn.SpatialConvolution(192 -> 10, 1x1)
  (22): cudnn.ReLU
  (23): cudnn.SpatialAveragePooling(8,8,1,1)
  (24): cudnn.SoftMax
}
ConfusionMatrix:
[[     894       4      23       7       8       1       7       5      44       7]   89.400%
 [       7     947       2       2       1       1       1       1      11      27]   94.700%
 [      24       0     857      25      30      20      29       8       6       1]   85.700%
 [      13       1      29     783      33      90      31       9       4       7]   78.300%
 [       2       1      19      16     918       9      20      13       2       0]   91.800%
 [       1       3      13      83      30     834      10      21       1       4]   83.400%
 [       4       1      21      15      20       6     926       2       3       2]   92.600%
 [       6       1      13      13      30      18       5     911       1       2]   91.100%
 [      21      12       4       2       0       0       4       0     950       7]   95.000%
 [      13      34       2       2       0       0       1       1      10     937]]  93.700%
 + average row correct: 89.569999575615%
 + average rowUcol correct (VOC measure): 81.334760189056%
 + global correct: 89.57%

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment