【问题标题】:Why the results of pycaffe backward is always 0?为什么pycaffe向后的结果总是0?
【发布时间】:2018-12-09 02:40:32
【问题描述】:
net.blobs['data'].data[...] = transformed_image
output = net.forward()

output_prob = output['prob'][0]  # the output probability vector for the 
first image in the batch

print 'predicted class is:', output_prob.argmax()

label_index = output_prob.argmax()
caffeLabel = np.zeros((1,1000))
caffeLabel[0,label_index] = 1;

vis_layer = 'pool5' # visualization layer

grads=net.backward(diffs=[vis_layer],**{'prob':caffeLabel})
print(np.sum(grads))

我想用这种方式获取渐变,但是print(np.sum(grads))总是0,我换了图层conv5或者其他图层,都没用!

【问题讨论】:

    标签: caffe pycaffe


    【解决方案1】:

    我已经解决了这个问题,将以下代码添加到 'deploy.prototxt'

    force_backward:true
    

    【讨论】:

      猜你喜欢
      • 2016-07-20
      • 1970-01-01
      • 2021-04-14
      • 2011-12-28
      • 2011-12-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2021-11-16
      相关资源
      最近更新 更多