caffe SSD 새 레이어 추가 문제

4987 단어
ffe 코드는 10000번 교체할 때 테스트를 해야 하는데 테스트를 할 때 문제가 발생합니다.
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 소스 코드는 왜 테스트를 할 때 매번 얻는blob의 width와 5를 비교합니까?
△△△△△△△△△△△△△△△△△△ solver 소스코드 분할선△△△ △ △ △ △ △ △ △ △ △ △ △ △
    Dtype iter_loss;
    const vector*>& 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(result_vec[k * 5]);
        int label = static_cast(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(result_vec[k * 5 + 2]);
          } else {
            all_num_pos[j][label] += static_cast(result_vec[k * 5 + 2]);
          }
        } else {
         //Normal row storing detection status.
          float score = result_vec[k * 5 + 2];
          int tp = static_cast(result_vec[k * 5 + 3]);
          int fp = static_cast(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,

좋은 웹페이지 즐겨찾기