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

Shape mismatch when using combining layers in Caffe

我正在使用 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)

据我所知,我使用名称 combined 下的连接层的方式与 BVLC_GoogLeNet. The concat layer can be found in my train.prototxt at pastebin 中的方式完全相同。我的输入 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)

这个错误是什么意思?以及如何解决?

更新

如评论中所述,日志仅包含错误。错误的堆栈跟踪如下:

@     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 "path",即没有 CONCAT 层。

我认为您遇到的问题是您的 train 网络已更新为具有连接层,而您的 test 网络没有。

这将解释您在考虑 concat 合并两个 400x400 层时遇到的 400x400 与 400x800 问题。没有看到你的测试网我不能确定。