【发布时间】:2016-04-17 11:47:31
【问题描述】:
我已经对我的数据集上的 imagenet 预训练模型进行了微调,以下是在 train_val.prototxt 中所做的相关更改(我也没有进行过采样,只是在准备 hdf5 时进行了中心裁剪)
name: "MyCaffeNet"
layer {
type: "HDF5Data"
name: "data"
top: "X"
top: "Meta"
top: "Labels"
hdf5_data_param {
source: "/path/to/hdf5_train.txt"
batch_size: 50
}
include { phase: TRAIN }
}
layer {
type: "HDF5Data"
name: "data"
top: "X"
top: "Meta"
top: "Labels"
hdf5_data_param {
source: "/path/to/hdf5_test.txt"
batch_size: 50
}
include { phase: TEST }
}
layer {
name: "conv1"
type: "Convolution"
bottom: "X"
其余的都一样,直到
layer {
name: "concat"
bottom: "fc7"
bottom: "Meta"
top: "combined"
type: "Concat"
concat_param {
concat_dim: 1
}
}
layer {
name: "my-fc8"
type: "InnerProduct"
bottom: "combined"
top: "my-fc8"
# lr_mult is set to higher than for other layers, because this layer is starting from random while the others are already trained
param {
lr_mult: 10
decay_mult: 1
}
param {
lr_mult: 20
decay_mult: 0
}
inner_product_param {
num_output: 4098
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "my-fc9"
type: "InnerProduct"
bottom: "my-fc8"
top: "my-fc9"
# lr_mult is set to higher than for other layers, because this layer is starting from random while the others are already trained
param {
lr_mult: 10
decay_mult: 1
}
param {
lr_mult: 20
decay_mult: 0
}
inner_product_param {
num_output: 1
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "loss"
type: "EuclideanLoss"
bottom: "my-fc9"
bottom: "Labels"
}
layer {
name: "loss"
type: "EuclideanLoss"
bottom: "my-fc9"
bottom: "Labels"
top: "loss"
include {
phase: TEST
}
}
问题是我不知道如何修改我的 deploy.prototxt 和我的特征提取代码(如下所示)来测试这个模型,现在将额外的元信息作为输入特征
for i=1:n
im = fgetl(file_list);
im = imread(im);
input_data = {prepare_image(im)};
scores = caffe('forward', input_data);
scores_original=scores;
scores = scores{1};
scores = squeeze(scores);
end
这里 prepare_image 将 rgb 转换为 bgr、置换和居中裁剪内容,基本上是预处理。
所以,归结为我应该如何修改 'caffe('forward', input_data)';并制作一个 deploy.prototxt 以便在测试 caffe 的同时也提供 Meta (n*2) 功能。感谢您的耐心和帮助!
我认为 deploy.prototxt 开头应该是这样的
name: "MyCaffeNet"
input: "X"
input_dim: 1
input_dim: 3
input_dim: 227
input_dim: 227
input: "Meta"
input_dim: 1
input_dim: 1
input_dim: 1
input_dim: 2 # two additional 'features' per image
【问题讨论】:
-
如果有人也能验证train_val的正确性,我将不胜感激!
-
基本上,如果我可以将 2 个输入 blob 传递给 caffe forward 函数,例如 caffe('forward',image_data,meta_data) 我的问题就会解决。
-
对不起,我不能很快确定你的问题。但是如果你想“将train_val.prototxt转换为deploy.prototxt”可以点击HERE
标签: matlab input hdf5 caffe conv-neural-network