Intel Caffe With ImageNet

Intel Caffe With ImageNet

Hi All,

I have the ImageNet data and want to test Intel Caffe on it. I am reading lot of tutorials, however I am getting confused how exactly is this raw data used. 

For example, in below command as per Intel article, it's bench marking the training model. However, without taking the raw data how can it benchmark or I am missing something here?

/opt/caffe/build/tools/caffe time --model=/opt/caffe/models/mkl2017_alexnet/train_val.prototxt

If anyone can point me to better documentation which can help me understand details, I will appreciate it. This is first time I am working with a learning framework, so will take time for me to get hang of it.

Thanks.

Chetan Arvind Patil
16 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

Dear Chetan,

Please take a look at the below link for reference. It is using the LeNet, you can tweak a bit to use your own choice of network. Please let me know if any doubts arise while attempting to replicate

 

https://software.intel.com/en-us/articles/training-and-deploying-deep-learning-networks-with-caffe-optimized-for-intel-architecture?05092016

 

Thanks

Anand

Hi Anand,

On another thread, you shared following suggestion:

引文:

Anandakrishnan C. (Intel) 写道:

It is not that ImageNet will not work in Intel Caffe, I have never downloaded it personally for any purpose. What I do is download the ImageNet trained model and use it for other use cases, so that I can have the learning transferred to my own cases and I do not want to train it again.

Is there any blog post on how to do this with Intel Caffe? I am realizing that Caffe (BVLC) is known for not so good documentation.

Is it possible to use ImageNet CNN model for quick testing? If yes, please share some steps. 

Thanks.

Chetan Arvind Patil

Dear Chetan,

I am not sure, If I understood your question fully, but what I guess is you want to use a Pretrained ImageNet model to test a few images to see how accurately it classifies? Am I correct?

 

 

Dear Chetan,

Can you share me the train_val.prototxt. Also please confirm if you have the LMDB available in the path as highlighted below:

data_param {

 
    source: "examples/imagenet/ilsvrc12_train_lmdb"

 
    batch_size: 256

 
    backend: LMDB

 
  }

Hi Anand,

引文:

Anandakrishnan C. (Intel) 写道:

I am not sure, If I understood your question fully, but what I guess is you want to use a Pretrained ImageNet model to test a few images to see how accurately it classifies? Am I correct?

Yes. But, I have the data now, so for my understanding I can do this from scratch.

引文:

Anandakrishnan C. (Intel) 写道:

Can you share me the train_val.prototxt. Also please confirm if you have the LMDB available in the path as highlighted below:

data_param {

     source: "examples/imagenet/ilsvrc12_train_lmdb"

     batch_size: 256

     backend: LMDB

  }

Please find attached train_val.prototxt file from: /data/deep-learning/intel-caffe/models/intel_optimized_models/alexnet

LMDB is not present as I haven't completed the step. Please check below question number 3.

----

I have all the raw data I need for "ILSVRC2012" and can use this to set up Caffe + ImageNet from scratch. I will share steps of what I have done, so that you have better details and can help me accordingly.

Steps I have followed:

  1. I build Caffe and it's in following path: /data/deep-learning/intel-caffe with binary in /data/deep-learning/intel-caffe/build/tools
  2. I have downloaded the ImageNet ILSVRC 2012 data and prepared it by following this guide on GitHub. So, I have following data folders:
    1. test: /data/deep-learning/imagenet-data-set/ILSVRC2012/test/images/folder
    2. train: /data/deep-learning/imagenet-data-set/ILSVRC2012/train/images/folder
    3. train_t3: /data/deep-learning/imagenet-data-set/ILSVRC2012/train_t3/images/folder
    4. val: /data/deep-learning/imagenet-data-set/ILSVRC2012/val/images/folder
  3. Executed command to get auxiliary data for training: ./data/ilsvrc12/get_ilsvrc_aux.sh

Now, before I go for next step, I have following questions:

  1. Do I need to resize all the data as per the steps given here. If yes, will the bash script suggested work?
  2. If I do above step, will that resize both the "train" (2.a above) and "val" (2.d above) data OR just "train" data?
  3. When generating LMDB file, will it have both "train" and "val" data OR just "train" data.
  4. Output of LMDB will be kept inside the Caffe directory in the path: /data/deep-learning/intel-caffe/examples/imagenet ?

Thanks.

 

Attachments: 

AttachmentSize
Downloadtext/plain train_val.prototxt.txt5.6 KB
Chetan Arvind Patil

Hi Anand,

Quote:

Chetan Arvind Patil wrote:

Now, before I go for next step, I have following questions:

  1. Do I need to resize all the data as per the steps given here. If yes, will the bash script suggested work?
  2. If I do above step, will that resize both the "train" (2.a above) and "val" (2.d above) data OR just "train" data?
  3. When generating LMDB file, will it have both "train" and "val" data OR just "train" data.
  4. Output of LMDB will be kept inside the Caffe directory in the path: /data/deep-learning/intel-caffe/examples/imagenet ?

For above questions. I understood following:

  • Q1: I don't need to use the said script, as "create_imagenet.sh" has resize implementation.
  • Q2: Since, "create_imagenet.sh" has two loops one for "train" another for "val" so both are getting resized.
  • Q3: Two separate LMDB are created.
  • O4: Output is created as per the path inside "examples/imagenet/<train/val>.lmdb.

Hopefully, when I run intel_optimized_models, I will get better understanding on bench marking and output of Caffe.

Thanks.

Chetan Arvind Patil
Best Reply

Dear Chetan,

I would suggest you to follow https://github.com/intel/caffe/tree/master/examples/imagenet for a much more detailed illustration

Do I need to resize all the data? 

The Resizing is done based on the network/topology choices, already in the transform section of train_val.prototxt there is an attribute called crop_size or resize param. This will take care of resizing during training or testing process. Also while creating LMDB files you have an option to resize the images if needed which would help to decrease the size of the LMDB. For LMDB creation please use the script below:

https://github.com/intel/caffe/blob/master/examples/imagenet/make_imagenet_mean.sh

For Computing Image mean

https://github.com/intel/caffe/blob/master/examples/imagenet/make_imagenet_mean.sh

 

If I do above step, will that resize both the "train" (2.a above) and "val" (2.d above) data OR just "train" data?

            It would resize both the train and the Validation data, you could also modify the script in however way you want

When generating LMDB file, will it have both "train" and "val" data OR just "train" data.?

           YES it would generate both train and validation LMDB

Output of LMDB will be kept inside the Caffe directory in the path:

         You can edit the LMDB generation script to control the path

 

 

Thanks

Anand

 

 

 

 

 

 

 

 

Hi Anand,

Thank you.

For ImageNet, I have completed all the steps and have the ILSVRC2012 data ready. If I am correct, then training set of ILSVRC2012 has millions of images. I started training it, however terminated it after I realized it is taking too much time > 12 hours. Is this accepted or I am doing something wrong? I have resized the files and followed all the steps without skipping anything.

In ILSVRC2012, apart from train and test images, there is train_3 data (also val data). Val data I guess is used for validation. Test data for testing during training. However, I don't understand reason for train_3 data.

Has Intel does full training for any of the ImageNet data set to see how much time it takes for training?

Thanks.

Chetan Arvind Patil

Dear Chetan,

The ImageNet data is really huge and it might run for many weeks. As I initially mentioned, you should be leveraging the concept of "Transfer Learning" if you are training your custom images. This would benefit even if you have fewer images. You can initialize your model with a Trained ImageNet model / COCO Model available at Caffe Model Zoo so as to make your convergence faster.

Thanks

Anand

Hi Anand,

I understand your idea. But, with transfer learning, Intel Xeon Phi is not being tested for the training part on larger data set, which is major part of the problem. Validation on trained ImageNet model and then comparing performance of validation, rather than training is not the correct way to do performance analysis?

Since, I already have this big data set from ImageNet, is it possible to use small set (subsetting 1M ImagetNet data to 10K images etc) of these data set and perform training on it? This way, I can keep my dataset same and use different models on it.

Thanks.

Chetan Arvind Patil

Dear Chetan,

If you objective is Performance analysis / benchmarking on Intel Xeon Phi(using ImageNet), you may do the training from scratch. But if your goal is to create a classification model out of you image set , transfer learning is the way out since it makes the convergence very easy. In the former case, since you are training from scratch, 1 million images will definitely take weeks to converge. You can also try sub setting in few thousands of images. But kindly make sure that, the dataset is not becoming skewed while you do the sub setting.  Once you are successful with training please let me know. Also please create a new ticket if you see any huge performance issues

Thanks

Anand 

Hi Anand,

Has Intel stressed Xeon Phi for full training set? Are there any technical document I can refer? Because, performance analysis shown for BVLC Caffe vs Intel Caffe is not for training, if I am correct.

Thanks.

Chetan Arvind Patil

Der Chetan,

You can always do training on Xeon Phi and you will definitely see a significant difference in performance when compared to BVLC Caffe. Please start with the training and let me know if you are able to progress. Also please let us know if you see any serious performance losses

 

Thanks

Anand

Dear Chetan,

Are there any more questions pending on this thread?

Thanks

Anand

Hi Anand,

No.

Thanks.

Chetan Arvind Patil

Leave a Comment

Please sign in to add a comment. Not a member? Join today