I used a custom dice loss layer in my caffe network for binary image segmentation. Everything works fine when I trained it using caffe command line:
$ caffe train -solver solver.prototxt
It did converge properly. But when I tried to train the same network using python wrapper:
solver = caffe.get_solver('solver.prototxt')
solver.solve()
I got an error:
File "dice_loss_layer.py", line 42, in forward
ValueError: could not broadcast input array from shape (32,160,128) into shape (32,1,160,128)
Actually line 42 in dice loss is an empty line and the line above and below it are comment lines. If I replace the dice loss layer with a regular softmax layer, the error disappeared. But since dice worked well with the command line, I couldn't find anything wrong in the loss layer itself.
The only difference I notice between the dice loss layer and the softmax layer is the number of output fed to dice is 1 while to softmax is 2. I don't really know where to look at to solve the problem. Could anyone give me some directions?