我在尝试使用自己的数据集训练LeNet。我从我的长1D向量数据集中生成了HDF5文件,并按如下方式创建了HDF5数据层:我在生成HDF5文件时使用了相同的名称来命名顶层blob。
name: "Test_net"
layer {
name: "data"
type: "HDF5Data"
top: "Inputdata"
top: "label"
hdf5_data_param {
source:"~/*_hdf5_train.txt"
batch_size: 32
}
include{phase: TRAIN}
}
layer {
name: "data2"
type: "HDF5Data"
top: "Inputdata"
top: "label"
hdf5_data_param {
source:"~/*_hdf5_test.txt"
batch_size: 32
}
include{phase: TEST}
}
layer {
name: "conv1"
type: "convolution"
bottom: "data"
top: "conv1"
param {lr_mult:1}
param {lr_mult:2}
convolution_param{
num_output: 20
kernel_h: 1
kernel_w: 5
stride_h: 1
stride_w: 1
weight_filler {
type: "xavier"
}
bias_filler {
type: "xavier"
}
}
}
layer {
name: "pool1"
type: "pooling"
bottom: "conv1"
top: "pool1"
pooling_param{
pool: MAX
kernel_h: 1
kernel_w: 2
stride_h: 1
stride_w: 2
}
}
# 这里有更多层...
layer{
name: "loss"
type: "SigmoidCrossEntropyLoss"
bottom: "ip2"
bottom: "label"
top: "loss"
}
但当我尝试训练时,从insert_split.cpp
中得到了以下错误。
insert_splits.cpp:29] Unknown bottom blob 'data' (layer 'conv1', bottom index 0) *** Check failure stack trace: *** @ 0x7f19d7e735cd google::LogMessage::Fail() @ 0x7f19d7e75433 google::LogMessage::SendToLog() @ 0x7f19d7e7315b google::LogMessage::Flush() @ 0x7f19d7e75e1e google::LogMessageFatal::~LogMessageFatal() @ 0x7f19d82684dc caffe::InsertSplits() @ 0x7f19d8230d5e caffe::Net<>::Init() @ 0x7f19d8233f21 caffe::Net<>::Net() @ 0x7f19d829c68a caffe::Solver<>::InitTrainNet() @ 0x7f19d829d9f7 caffe::Solver<>::Init() @ 0x7f19d829dd9a caffe::Solver<>::Solver() @ 0x7f19d8211683 caffe::Creator_SGDSolver<>() @ 0x40a6c9 train() @ 0x4071c0 main @ 0x7f19d6dc8830 __libc_start_main @ 0x4079e9 _start @ (nil) (unknown) Aborted (core dumped)
我哪里做错了?
祝好,
回答:
你的数据层输出两个“blob”:"label"
和 "Inputdata"
。你的"conv1"
层期望输入一个名为"data"
的“blob”。Caffe并不知道你认为"Inputdata"
和"data"
是同一个blob…
现在,由于你已经用"Inputdata"
名称保存了hdf5文件,你无法在"HDF5Data"
层中更改此名称,你可以做的就是在"conv1"
层的“bottom”中将"data"
改为"Inputdata"
。
附言,
你的损失层需要两个“bottom”:ip2
和 label
,你忘记提供这些了。