How to modify Caffe network input for C++ API?

537 views
Skip to first unread message

Jack Simpson

unread,
Aug 25, 2015, 11:34:28 AM8/25/15
to Caffe Users

I'm trying to use the MINST Caffe example via the C++ API, but I'm having a bit of trouble working out how to restructure the network prototxt file I'll deploy after training. I've trained and tested the model with the original file (lenet_train_test.prototxt), but when I want to deploy it and make predictions like in the C++ and OpenCV example, I realise I have to modify the input section to make it similar to the deploy.prototxt file they have.

Can I replace the information in the training and testing layers of the lenet_train_test.prototxt with this section of the deploy.prototxt file?

name: "CaffeNet"
input: "data"
input_shape {
  dim: 10
  dim: 3
  dim: 227
  dim: 227
}

The images I'll be passing for classification to the network will be grayscale and 24*24 pixels, and I'll also want to scale it like was done with the MINST dataset, so could I modify the section to this?

name: "CaffeNet"
input: "data"
input_shape {
  dim: 10
  dim: 1
  dim: 24
  dim: 24
}
transform_param {
scale: 0.00390625
}

I'm not entirely sure what the "dim: 10" is coming from though.

Saman Sarraf

unread,
Apr 6, 2016, 2:51:46 PM4/6/16
to Caffe Users
10 in the number of image . 

Saman Sarraf

unread,
Apr 6, 2016, 2:53:27 PM4/6/16
to Caffe Users
How did you handle the scaling? 
I'm getting an error when I add transform_param after input_shape layer. How should I solve it ?

Jan

unread,
Apr 15, 2016, 10:06:38 AM4/15/16
to Caffe Users
Yeah, this is all correct but for the transform param. In a deploy type network def you simply cannot give an input transform, that has to be done by the user. This is one of the things that hopefully get fixed at sometime. Yes, 10 is the batchsize, but that can be easily changed by the user with a net.blobs['data'].reshape(...). The other three 'dim's are more critical.

Recently there is a new layer type called "Input" that has the same functionality as the previous "input" and "input_shape" properties: It simply declares blobs with these names, and does nothing else. Maybe someday it will be possible to define a data transform in this layer as well.

Jan
Reply all
Reply to author
Forward
0 new messages