【发布时间】:2019-03-04 06:40:17
【问题描述】:
我已经在 Caffe 上训练了一个 googlenet,现在我想做测试,所以我使用 deploy.prototxt 和预训练的权重并将它们分配给 Net。但是我收到了这个错误(有趣的是在一条消息说网络已初始化之后)
I0927 17:51:41.171922 5336 net.cpp:255] Network initialization done.
I0927 17:51:41.195708 5336 net.cpp:744] Ignoring source layer label_imgdata_1_split
F0927 17:51:41.195746 5336 blob.cpp:496] Check failed: count_ == proto.data_size() (9408 vs. 0)
显然,由于这里的字符限制,我无法复制粘贴整个 prototxt。我正在添加它的外观,而没有或多或少相同的主体(阶段:训练和阶段:c 的测试部分除外)。正文与此处的示例相同:https://github.com/BVLC/caffe/tree/master/models/bvlc_googlenet
注意:我在训练期间读入 hdf5 数据,在测试期间只使用 python 脚本(我执行与创建 hdf5 数据时相同的预处理 / 所以我不使用 caffe 的 io.transform 并且我不使用'根本不减去平均值(这种方式效果更好))-尽管错误是在初始化期间而不是在数据部分中读取
我的部署是什么样子的:
name: "GoogleNet"
layer {
name: "data"
type: "Input"
top: "data"
input_param { shape: { dim: 10 dim: 3 dim: 224 dim: 224 } }
}
.....
layer {
name: "loss3/classifier"
type: "InnerProduct"
bottom: "pool5/7x7_s1"
top: "loss3/classifier"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 7
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "prob"
type: "Softmax"
bottom: "loss3/classifier"
top: "prob"
}
这是我的火车 prototxt 的样子:
name: "GoogleNet"
layer {
name: "imgdata"
type: "HDF5Data"
top: "label"
hdf5_data_param {
source: "/media/DATA/DetDataWOMeanSubt/train_h5_list.txt"
batch_size: 64
shuffle: true
}
include {
phase: TRAIN
}
}
layer {
name: "imgdata"
type: "HDF5Data"
top: "imgdata"
top: "label"
hdf5_data_param {
source: "/media/DATA/DetDataWOMeanSubt/eval_h5_list.txt"
batch_size: 128
shuffle: true
}
include {
phase: TEST
}
}
....
layer {
name: "loss3/classifier"
type: "InnerProduct"
bottom: "pool5/7x7_s1"
top: "loss3/classifier"
inner_product_param {
num_output: 7
weight_filler {
type: "xavier"
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "loss"
type: "SoftmaxWithLoss"
bottom: "loss3/classifier"
bottom: "label"
top: "loss"
loss_weight: 1
}
layer {
name: "accuracy/top-1"
type: "Accuracy"
include { phase: TEST }
bottom: "loss3/classifier"
bottom: "label"
top: "accuracy/top-1"
accuracy_param { top_k: 1 }
}
这是我初始化网络的方法:
net = caffe.Net(model_def, # defines the structure of the model
model_weights, # contains the trained weights
caffe.TEST) # use test mode (e.g., don't perform dropout)
在网络初始化之前我确实收到了这个警告(它似乎仍然在继续初始化网络)
DEPRECATION WARNING - deprecated use of Python interface
W0927 17:51:40.486548 5336 _caffe.cpp:140] Use this instead (with the named "weights" parameter):
W0927 17:51:40.486551 5336 _caffe.cpp:142] Net('/home/x/Desktop/caffe-caffe-0.16/models/bvlc_googlenet/deploy.prototxt', 1, weights='/home/x/Desktop/caffe-caffe-0.16/models/bvlc_googlenet/logs_iter_60000.caffemodel')
(但是当我按照建议做时它不起作用)
我在使用Caffe之前已经做了很多次测试,我不知道为什么这不起作用。
【问题讨论】:
标签: conv-neural-network caffe pycaffe