Skip to first unread message

filipe mutz

unread,
Aug 11, 2015, 7:26:48 PM8/11/15
to Caffe Users
Hi everyone! I have a simple question and couldn't find an answer after a long time of exploration. Hope you can give me some direction. 

I am using a HDF5 data layer to read my testing set. The question is: how can I extract from Caffe's data structure the number of items in the data set? For example, if my set has 32K 200x200 pixels grayscale images. Where can I find the 32K? I found the other information using net.blob_by_name("name of the blob")->shape(id). Id = 0 returns the batch size, Id = 1 returns the number of channels,  Id = 2 returns the height, and Id = 3 returns the width (the last two may be inverted), I can't found the number of itens (32K) anywhere though. 

I need this information to compare the net output with my expected output in order to calculate the net's precision. Are there a better way of doing it than the for showed below? Can you give me some example?

-------------------------------------------------------------------
for(int k = 0; k < [Number of Itens]; k++)
{
net.ForwardPrefilled(&loss);

shared_ptr < Blob<float > > out = net.blob_by_name("Net Output");
shared_ptr < Blob<float > > in = net.blob_by_name("Net Input");

float expected = in->cpu_data()[0]; 
float predicted = out->cpu_data()[0];

error = pow(expected - predicted, 2);
}
------------------------------------------------------------------

Thanks for any help!
Reply all
Reply to author
Forward
0 new messages