How to caculate forward and backward time for my own dataset?

401 views
Skip to first unread message

X.T. Li

unread,
Aug 13, 2015, 4:45:43 AM8/13/15
to Caffe Users
I want to test caffe on my own dataset using the pre-trained caffenet model. I know python can implement this, but is it possible to use python to benchmark forward time and backward time? Or do I have to use ./build/tools/caffe time to get the benchmark? If so, how can I run this command with my own dataset instead of the default one?
Message has been deleted

林子達

unread,
Aug 13, 2015, 11:55:46 PM8/13/15
to Caffe Users

$ cd caffe
$ ./build/tools/caffe time --model=models/bvlc_alexnet/deploy.prototxt
  Change to 
$ ./build/tools/caffe time --model=[your/model/path]/deploy.prototxt

X.T. Li

unread,
Aug 14, 2015, 12:33:15 AM8/14/15
to Caffe Users
Thanks for you reply. But I mean testing using my own data, with pre-trained model provided by caffe. I don't know when rum caffe time --model=models/bvlc_alexnet/deploy.prototxt, what dataset caffe uses.

在 2015年8月14日星期五 UTC+8上午11:55:46,林子達写道:

Christos Nikolaou

unread,
Aug 14, 2015, 7:40:23 PM8/14/15
to Caffe Users
I am not 100% sure, but I believe that ./build/tools/caffe time --model=[your/model/path] calculated the time that the model needs to do the forward and backward pass on your dataset. I believe this because you dataset's path is defined in your model.prototxt file and thus Caffe ought to use that input. However, I do not know excactly if it calculates the time based on a hole batch, or per input data point (batch_time/batch_size), or something else.

Xueting Li

unread,
Aug 15, 2015, 12:08:35 AM8/15/15
to Caffe Users
Thanks, do you know how to define my dataset's path in model.prototxt? Do I need to preprocess my data so it is in hdf5 format or something like that? Also, I think the time is for batch time, I tried to change batch size and get different time for each batch size, and time for per image decreases as batch size increases untill batch size is bigger than about 128.

在 2015年8月15日星期六 UTC+8上午7:40:23,Christos Nikolaou写道:

Christos Nikolaou

unread,
Aug 15, 2015, 6:13:34 AM8/15/15
to Caffe Users
At your model.prototxt file the first layer should be a data layer. When defining a data layer you chose the source that will be used. For example the following code is similar to the data layer definition which can be found to the ImageNet tutorial and specifically from the train_val.prototxt file:

Εισαγωγή κώδικα εδώ...layer {
  name
: "data"
  type
: "Data"
  top
: "data"
  top
: "label"
  transform_param
{
    mirror
: true
    crop_size
: 227
    mean_file
: "data/ilsvrc12/imagenet_mean.binaryproto"
 
}
  data_param
{
    source
: "examples/imagenet/ilsvrc12_train_lmdb"
    batch_size
: 256
    backend
: LMDB
 
}


In the data_param field you choose the input of your network (the dataset's path that you need), the backend that you use (LMDB) and the batch size. I do not think that the data should be in HDF5 format; I believe that it can be in any form as long as you put the right backend type. Also, it might be better to be in the LMDB format because it is more frequently used, unless you have got other reasons to use something else.

Christos Nikolaou

unread,
Aug 15, 2015, 6:14:25 AM8/15/15
to Caffe Users
(Ignore the Greek words in the code example; can't find a way to edit my post)


Τη Σάββατο, 15 Αυγούστου 2015 - 1:13:34 μ.μ. UTC+3, ο χρήστης Christos Nikolaou έγραψε:
At your model.prototxt file the first layer should be a data layer. When defining a data layer you chose the source that will be used. For example the following code is similar to the data layer definition which can be found to the ImageNet tutorial and specifically from the train_val.prototxt file:

Reply all
Reply to author
Forward
0 new messages