Caffe:概率输出大于1的分类器

Caffe: classifier with probabilistic output greater than 1

我正在尝试 运行 使用 python 在 cifar-10 数据上使用 Caffe。我的proto.txt到此结束(注意:我的部署文件没有损失层!)

...
layer {
  name: "ampl"
  type: "InnerProduct"
  bottom: "maxPool1"
  top: "ampl"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  inner_product_param {
    num_output: 10
    bias_term: false
    weight_filler {
      type: "gaussian"
      std: 0.01
    }
    bias_filler {
      type: "constant"
      value: 0.2
    }
  }
}
layer {
  name: "loss"
  type: "Softmax"
  bottom: "ampl"
  bottom: "label"
  top: "loss"
}

但是当我查看我的输出概率时,它们不是 [0 1]。 这也是我在测试阶段读取输出标签的方式:

net = caffe.Net(modelFile, weightsFile, caffe.TEST)

# estimate amplitude
shape = (data.shape[0], net.blobs['ampl'].data.shape[1])
dtype = net.blobs['ampl'].data.dtype

aE = np.ndarray(shape,dtype)

for i in range(data.shape[0]):
    net.blobs['data'].data[...] = data[i].reshape(net.blobs['data'].data.shape)
    net.forward()
    aE[i,:] = net.blobs['ampl'].data

这是前 5 个样本的输出:

   -0.8576         0         0         0   -1.2853
   -1.1855         0         0         0   -0.3572
   -2.2088         0         0         0   -2.6844
   -1.2650         0         0         0   -3.8973
   -1.2844         0         0         0   -3.8011
   -1.5247         0         0         0   -3.9778
   -1.6097         0         0         0   -3.7351
   -1.0909         0         0         0   -3.6270
   -1.3660         0         0         0   -0.4569
   -1.0892         0         0         0   -0.2500

似乎你正在输出 "ampl" 层,这是一个全连接层,只有 softmax 会产生实际概率,所以你应该输出包含 softmax 操作的层(没有损失,只有 softmax)。

您也可以输出最后一层并手动应用 softmax。