What is the difference of training a caffe network using command line and python wrapper?

只谈情不闲聊 提交于 2019-12-11 07:15:13

问题


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?

来源:https://stackoverflow.com/questions/42791280/what-is-the-difference-of-training-a-caffe-network-using-command-line-and-python

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!