caffe SSD 添加新层时出现的问题
2017-05-12 14:50
357 查看
caffe代码,在迭代10000次的时候需要进行test,但是test的时候遇见问题。
I0512 14:40:29.685868 15163 upgrade_proto.cpp:77] Attempting to upgrade batch norm layers using deprecated params: snapshot_iter_10000.caffemodel
I0512 14:40:29.685925 15163 upgrade_proto.cpp:80] Successfully upgraded batch norm layers using deprecated params.
I0512 14:40:29.710816 15163 sgd_solver.cpp:356] SGDSolver: restoring history
I0512 14:40:29.788755 15163 caffe.cpp:251] Starting Optimization
I0512 14:40:29.788800 15163 solver.cpp:294] Solving VGG_VOC0712_SSD_300x300_test_train
I0512 14:40:29.788805 15163 solver.cpp:295] Learning Rate Policy: multistep
I0512 14:40:29.799832 15163 solver.cpp:433] Iteration 10000, Testing net (#0)
I0512 14:40:29.817718 15163 net.cpp:693] Ignoring source layer mbox_loss
F0512 14:40:32.193830 15163 solver.cpp:464] Check failed: result[j]->width() == 5 (150 vs. 5)
*** Check failure stack trace: ***
@ 0x7f82cfdf75cd google::LogMessage::Fail()
@ 0x7f82cfdf9433 google::LogMessage::SendToLog()
@ 0x7f82cfdf715b google::LogMessage::Flush()
@ 0x7f82cfdf9e1e google::LogMessageFatal::~LogMessageFatal()
@ 0x7f82d04aef2c caffe::Solver<>::TestDetection()
@ 0x7f82d04afe39 caffe::Solver<>::TestAll()
@ 0x7f82d04aff3c caffe::Solver<>::Step()
@ 0x7f82d04b0abe caffe::Solver<>::Solve()
@ 0x40bcf4 train()
@ 0x4077c8 main
@ 0x7f82ce58e830 __libc_start_main
@ 0x408099 _start
@ (nil) (unknown)
Aborted (core dumped)
注:遇见问题,如果抛出错误,首先要去读源码。例如这个,要去solver.cpp中,看抛出的问题在什么地方。
看不懂代码也是悲伤!
SSD的solver源代码 为什么在test的时候,对每一次获得的blob 的width要和5进行对比呢?
*******************solver源代码分割线**********************
Dtype iter_loss;
const vector<Blob<Dtype>*>& result = test_net->Forward(&iter_loss);
if (param_.test_compute_loss()) {
loss += iter_loss;
}
for (int j = 0; j < result.size(); ++j) {
CHECK_EQ(result[j]->width(), 5);
const Dtype* result_vec = result[j]->cpu_data();
int num_det = result[j]->height();
for (int k = 0; k < num_det; ++k) {
int item_id = static_cast<int>(result_vec[k * 5]);
int label = static_cast<int>(result_vec[k * 5 + 1]);
if (item_id == -1) {
// Special row of storing number of positives for a label.
if (all_num_pos[j].find(label) == all_num_pos[j].end()) {
all_num_pos[j][label] = static_cast<int>(result_vec[k * 5 + 2]);
} else {
all_num_pos[j][label] += static_cast<int>(result_vec[k * 5 + 2]);
}
} else {
// Normal row storing detection status.
float score = result_vec[k * 5 + 2];
int tp = static_cast<int>(result_vec[k * 5 + 3]);
int fp = static_cast<int>(result_vec[k * 5 + 4]);
if (tp == 0 && fp == 0) {
// Ignore such case. It happens when a detection bbox is matched to
// a difficult gt bbox and we don't evaluate on difficult gt bbox.
continue;
}
all_true_pos[j][label].push_back(std::make_pair(score, tp));
all_false_pos[j][label].push_back(std::make_pair(score, fp));
}
}
}
}
***********************************2017/5/13*********************************
去git的主页上找到了一个人遇见了同样的问题,添加新的层会遇见同样的问题
原问题:
Thanks to Wei for the great work, and sharing it with everybody.
I need to get TEST loss during training, so that I can get some idea about how well the network is doing in generalization. In the python script I tried to add MultiBoxLoss layer to the test net the same way train net did, however it give me error at test
time:
solver.cpp:464 check failed: result[j]->width() ==5 (1 vs 5)
I am not familiar with the internals of Caffe, could you give me a pointer on proper way of enabling test loss in the Python script?
Your help is greatly appreciated.
作者回答:
I think you have to add a silence layer after the loss layer.
在python的接口的代码
in the python script,when you create the test net, after CreateMultiBoxHead, add these lines
also, add this to the solver_param:
I0512 14:40:29.685868 15163 upgrade_proto.cpp:77] Attempting to upgrade batch norm layers using deprecated params: snapshot_iter_10000.caffemodel
I0512 14:40:29.685925 15163 upgrade_proto.cpp:80] Successfully upgraded batch norm layers using deprecated params.
I0512 14:40:29.710816 15163 sgd_solver.cpp:356] SGDSolver: restoring history
I0512 14:40:29.788755 15163 caffe.cpp:251] Starting Optimization
I0512 14:40:29.788800 15163 solver.cpp:294] Solving VGG_VOC0712_SSD_300x300_test_train
I0512 14:40:29.788805 15163 solver.cpp:295] Learning Rate Policy: multistep
I0512 14:40:29.799832 15163 solver.cpp:433] Iteration 10000, Testing net (#0)
I0512 14:40:29.817718 15163 net.cpp:693] Ignoring source layer mbox_loss
F0512 14:40:32.193830 15163 solver.cpp:464] Check failed: result[j]->width() == 5 (150 vs. 5)
*** Check failure stack trace: ***
@ 0x7f82cfdf75cd google::LogMessage::Fail()
@ 0x7f82cfdf9433 google::LogMessage::SendToLog()
@ 0x7f82cfdf715b google::LogMessage::Flush()
@ 0x7f82cfdf9e1e google::LogMessageFatal::~LogMessageFatal()
@ 0x7f82d04aef2c caffe::Solver<>::TestDetection()
@ 0x7f82d04afe39 caffe::Solver<>::TestAll()
@ 0x7f82d04aff3c caffe::Solver<>::Step()
@ 0x7f82d04b0abe caffe::Solver<>::Solve()
@ 0x40bcf4 train()
@ 0x4077c8 main
@ 0x7f82ce58e830 __libc_start_main
@ 0x408099 _start
@ (nil) (unknown)
Aborted (core dumped)
注:遇见问题,如果抛出错误,首先要去读源码。例如这个,要去solver.cpp中,看抛出的问题在什么地方。
看不懂代码也是悲伤!
SSD的solver源代码 为什么在test的时候,对每一次获得的blob 的width要和5进行对比呢?
*******************solver源代码分割线**********************
Dtype iter_loss;
const vector<Blob<Dtype>*>& result = test_net->Forward(&iter_loss);
if (param_.test_compute_loss()) {
loss += iter_loss;
}
for (int j = 0; j < result.size(); ++j) {
CHECK_EQ(result[j]->width(), 5);
const Dtype* result_vec = result[j]->cpu_data();
int num_det = result[j]->height();
for (int k = 0; k < num_det; ++k) {
int item_id = static_cast<int>(result_vec[k * 5]);
int label = static_cast<int>(result_vec[k * 5 + 1]);
if (item_id == -1) {
// Special row of storing number of positives for a label.
if (all_num_pos[j].find(label) == all_num_pos[j].end()) {
all_num_pos[j][label] = static_cast<int>(result_vec[k * 5 + 2]);
} else {
all_num_pos[j][label] += static_cast<int>(result_vec[k * 5 + 2]);
}
} else {
// Normal row storing detection status.
float score = result_vec[k * 5 + 2];
int tp = static_cast<int>(result_vec[k * 5 + 3]);
int fp = static_cast<int>(result_vec[k * 5 + 4]);
if (tp == 0 && fp == 0) {
// Ignore such case. It happens when a detection bbox is matched to
// a difficult gt bbox and we don't evaluate on difficult gt bbox.
continue;
}
all_true_pos[j][label].push_back(std::make_pair(score, tp));
all_false_pos[j][label].push_back(std::make_pair(score, fp));
}
}
}
}
***********************************2017/5/13*********************************
去git的主页上找到了一个人遇见了同样的问题,添加新的层会遇见同样的问题
原问题:
Thanks to Wei for the great work, and sharing it with everybody.
I need to get TEST loss during training, so that I can get some idea about how well the network is doing in generalization. In the python script I tried to add MultiBoxLoss layer to the test net the same way train net did, however it give me error at test
time:
solver.cpp:464 check failed: result[j]->width() ==5 (1 vs 5)
I am not familiar with the internals of Caffe, could you give me a pointer on proper way of enabling test loss in the Python script?
Your help is greatly appreciated.
作者回答:
I think you have to add a silence layer after the loss layer.
在python的接口的代码
in the python script,when you create the test net, after CreateMultiBoxHead, add these lines
name = "test_loss" mbox_layers.append(net.label) net[name] = L.MultiBoxLoss(*mbox_layers, multibox_loss_param=multibox_loss_param, loss_param=loss_param, include=dict(phase=caffe_pb2.Phase.Value('TEST')), propagate_down=[True, True, False, False]) name="silence" net[name] = L.Silence(net['test_loss'],ntop=0)
also, add this to the solver_param:
'test_compute_loss':True,
相关文章推荐
- SSD(old)版本caffe安装在已安装新版本caffe的服务器,出现的问题及解决方案
- 在build.gradle文件中添加若干个依赖后出现以下问题,字面意思是测试app和正式app使用了不同版本的依赖
- 配置SSD-caffe出现“ AttributeError: 'module' object has no attribute 'LabelMap'”解决
- 关于VC6中基于对话框的程序,往Combox 添加一个CComboBox变量,然后程序编译运行,窗口不出现的问题
- ubuntu16.04下编译caffe出现.build_release/lib/libcaffe.so: undefined reference to google ::protobuf...的问题
- 使用SpringMVC时添加了web.xml中的DispatchServlet配置后出现Tomcat服务器无法启动的问题
- 多语言网店的产品详细页面跳转到购物车页面出现产品添加到购物车失败的问题的解决!!
- Android 百度map频繁添加覆盖物后刷新出现map闪烁有关问题
- SSD编译出现问题
- caffe0.16 resnet batch_size=64时出现超出gpu_memory问题
- Ubuntu16.04+anaconda2+caffe+ssd+opencv3.1.0在编译caffe过程中的问题及解决方法 主要遇到三个问题,前两个是caffe在cmake过程中的问题,后一
- Android ListView添加了HeaderView后,出现点击HeaderView区域跳转的问题
- Myeclipse添加外部Tomcat出现启动故障的问题解决
- 在UIAlterView的代理方法中 点击确定时 添加一个UIView到[[UIApplication sharedApplication].keyWindow上只出现了0.5秒左右就消失的问题
- CvvImage添加到工程出现的问题
- [vagrant]第一次安装添加box出现问题汇总
- zTree插件和layer弹出层结合进行添加,删除,修改操作时,针对出现调用父父页面方法出现问题,解决方法
- c#操作IIS 添加SSL出现的问题
- 数据传输出现乱码问题集合!!!不断添加!!
- 在UIAlterView的代理方法中 点击确定时 添加一个UIView到[[UIApplication sharedApplication].keyWindow上只出现了0.5秒左右就消失的问题