Caffe - Doing forward pass with multiple input blobs

╄→гoц情女王★ 提交于 2019-12-11 18:37:56

问题


Following are the input layers of my fine-tuned model:

layer {
  type: "HDF5Data"
  name: "data"
  top: "Meta" 
  hdf5_data_param {
    source: "/path/to/train.txt"
    batch_size: 50
  }
  include { phase: TRAIN }
}
layer {
  name: "data"
  type: "ImageData"
  top: "X"
  top: "Labels"
  include {
    phase: TRAIN
  }
  transform_param {
    mirror: true
    crop_size: 227
    mean_file: "data/ilsvrc12/imagenet_mean.binaryproto"
  }
  image_data_param {
    source: "/path/to/train.txt"
    batch_size: 50
    new_height: 256
    new_width: 256
  }
}
layer {
  type: "HDF5Data"
  name: "data"
  top: "Meta" 
  hdf5_data_param {
    source: "/path/to/val.txt"
    batch_size: 50
  }
  include { phase: TEST }
}
layer {
  name: "data"
  type: "ImageData"
  top: "X"
  top: "Labels"
  include {
    phase: TEST
  }
  transform_param {
    mirror: false
    crop_size: 227
    mean_file: "data/ilsvrc12/imagenet_mean.binaryproto"
  }
  image_data_param {
    source: "/path/to/val.txt"
    batch_size: 50
    new_height: 256
    new_width: 256
  }
}

As you can see it has one imagedata input layer and 1 hdf5 input layer, if there was only 1 type of layer say imagedata, I could have done:

input_data = {prepare_images(im)}; # dimension 227*227*3*10

and then scores = caffe('forward',input_data); But here I have to give two types of input data, how can I do this? Please help!


回答1:


I had to check matcaffe.cpp (and recompile with make matcaffe) and print the check variables for the 'Invalid Input Size' condition I was failing, to get the idea of transposing input_data which works.

input_data = {prepare_images(im),prepare_other_data()};
scores = caffe('forward', input_data');

Thus taking the transpose worked for me.



来源:https://stackoverflow.com/questions/34832161/caffe-doing-forward-pass-with-multiple-input-blobs

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!