首页 文章

在Caffe中使用组合图层时形状不匹配

提问于
浏览
3

我正在使用Caffe库来训练卷积神经网络(CNN) . 但是,在将两个卷积图层的输出应用到inner_product图层之前,使用concat图层组合输出时会出现以下错误 .

F1023 15:14:03.867435  2660 net.cpp:788] Check failed: target_blobs[j]->shape() == source_blob->shape() Cannot share param 0 weights from layer 'fc1'; shape mismatch.  Source param shape is 400 800 (320000); target param shape is 400 400 (160000)

据我所知,我使用concat层的方式与BVLC_GoogLeNet完全相同 . concat图层可以在我的train.prototxt中找到pastebin,名称为 combined . 我输入blob的尺寸为 256x8x7x24 ,其中Caffe中的数据格式为 batch_size x channels x height x width . 我尝试过使用pycaffe界面和控制台进行训练 . 我犯了同样的错误 . 以下是使用控制台进行培训的代码 .

solver_path = CAFFE_ROOT+'build/tools/caffe train -solver '
model_path = self.run_dir+'models/solver.prototxt'
log_path = self.run_dir+'models/training.log'

p = subprocess.Popen("GLOG_logtostderr=1 {} {} 2> {}".format(solver_path, model_path, log_path), shell=True, stdout=subprocess.PIPE, stderr=subprocess.STDOUT)

这个错误是什么意思?它怎么解决?

Update

正如评论中所提到的,日志只包含错误 . 错误的堆栈跟踪如下:

@     0x7f231886e267  caffe::Net<>::ShareTrainedLayersWith()
@     0x7f231885c338  caffe::Solver<>::Test()
@     0x7f231885cc3e  caffe::Solver<>::TestAll()
@     0x7f231885cd79  caffe::Solver<>::Step()
@     0x7f231885d6c5  caffe::Solver<>::Solve()
@           0x408d2b  train()
@           0x4066f1  main

还应该注意的是,我的求解器和代码可以很好地训练完全相同的CNN,只有1个“路径”沿着网络,即没有CONCAT层 .

1 回答

  • 1

    我相信你遇到的问题是你的 train 网已经更新为有一个concat层,而你的 test 网却没有 .

    它可以解释400x400与400x800的问题,你考虑将concat合并为两个400x400层 . 我无法确定无法看到你的测试网 .

相关问题