Can't understand a statement in an example

26 views
Skip to first unread message

Sergius Liu

unread,
Apr 21, 2017, 10:33:42 PM4/21/17
to Caffe Users
Here's a training example in caffe Jupyter example 

At block In [15]: 
for test_it in range(100):
            solver.test_nets[0].forward()
            correct += sum(solver.test_nets[0].blobs['score'].data.argmax(1)
                           == solver.test_nets[0].blobs['label'].data)
        test_acc[it // test_interval] = correct / 1e4

I can't understand what is the data structure behind this operation.  argmax(1), why (1)?  
'label' seems to be a character, how to make them equal?   

I can't understand the datastructure. Is there a website where I can get better understanding of them? 

Mahmoud Badr

unread,
Apr 22, 2017, 9:58:56 PM4/22/17
to Caffe Users
argmax arguments are the number of returns you want argmax function to return. for example, if i called argmax(2) in this context then I want the 2 highest probabilities. the labels are not characters, since you are doing classification your ground truth (label) is just an image. the line of code correct += sum(solver.test_nets[0].blobs['score'].data.argmax(1)
                           == solver.test_nets[0].blobs['label'].data)
is simply doing the following: after getting the output data (which is an image) from the score layer which has the highest probabilities (fetched by argmax) from the number of classes. if this image matches the label given then increment correct. correct will be the accuracy of the network. 
Reply all
Reply to author
Forward
0 new messages