Caffe-使用多个输入Blob进行前向传递 [英] Caffe - Doing forward pass with multiple input blobs

查看:161
本文介绍了Caffe-使用多个输入Blob进行前向传递的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

以下是我的微调模型的输入层:

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
  }
}

如您所见,它具有一个imagedata输入层和1个hdf5输入层,如果只有1种类型的层,例如imagedata,我可以做到:

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

,然后
scores = caffe('forward',input_data);
但是在这里我必须给出两种类型的输入数据,我该怎么做?

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!

推荐答案

我必须检查matcaffe.cpp(并使用make matcaffe进行重新编译),并打印' 输入大小无效的条件使我无法通过有效的方式来调换input_data。

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.

这篇关于Caffe-使用多个输入Blob进行前向传递的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆