Shape of input blob - siamese network

21 views
Skip to first unread message

Makiko

unread,
Apr 16, 2017, 8:11:21 PM4/16/17
to Caffe Users
Hello, 

can you help me with input data to siamese network?

I would like to train siamese network. Data layer in my train.prototxt is (type: "Input") - http://caffe.berkeleyvision.org/tutorial/layers/input.html. My image data are in numpy array of shape (N x 2 x C x H x W), where N is number of (pairs) images, 2 is the pair, C is channel (in my case 1 B&W), H is height and W is width. I have defined in my train.prototxt input_param
 
input_param {
    shape: {
      dim: 50
      dim: 1
      dim: 255
      dim: 255
      }
  }

what is shape of blob what the net expects.

My last layer is contrastiveloss.


My question is how should I feed the net with my data?
I guess that I should reshape my array somehow...

I planned to use slice layer after data layer.

Could you provide me a short example how to do that?

Thank you in advance.

Makiko W.

Przemek D

unread,
Apr 19, 2017, 5:01:36 AM4/19/17
to Caffe Users
If your data is 5-dimensional, so should be your input. In theory you would have to add another dim param equal to 2, but I never tried that in practice.
What I successfully used instead, was concatenating images side by side and then using the Slice layer to retrieve the individual ones. In your case the input would look like:

input_param {
  shape: {
    dim: 50
    dim: 1
    dim: 255
    dim: 510
  }
}
Then you'd simply feed two images as if they were one, and Slice them with param:
slice_dim: 3
slice_point: 255
Reply all
Reply to author
Forward
0 new messages