pir
pir

Reputation: 5923

Shape mismatch when using combining layers in Caffe

I'm using the Caffe library for training a convolutional neural network (CNN). However, I'm getting the following error when using the concat layer to combine the output from two convolutional layers before applying it to a inner_product layer.

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)

As far as I know I am using the concat layer in the exact same way as in BVLC_GoogLeNet. The concat layer can be found in my train.prototxt at pastebin under the name combined. The dimensions of my input blob is 256x8x7x24, where the data format in Caffe is batch_size x channels x height x width. I've tried training both using the pycaffe interface and the console. I get the same error. Below is code for training using the console.

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)

What is the meaning of this error? And how can it be resolved?

Update

As mentioned in the comments the log contains nothing else than the error. The stack trace for the error is the following:

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

It should also be noted that my solver and code works fine for training the exact same CNN with only 1 "path" along the network, i.e. without the CONCAT layer.

Upvotes: 3

Views: 2162

Answers (1)

Aidan Gomez
Aidan Gomez

Reputation: 8627

I believe the issue you're having is that your train net has been updated to have a concat layer while your test net hasn't.

It would explain the 400x400 vs 400x800 issue you're having considering your concat merges two 400x400 layers. I can't know for certain without being able to see your test net.

Upvotes: 1

Related Questions