Caffe输出层数精度 [英] Caffe output layer number accuracy

查看:300
本文介绍了Caffe输出层数精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我修改了Caffe MNIST示例,将3类图片。我注意到的一个事情是,如果我指定输出层数为3,那么我的测试精度下降到低到40%的范围。但是,如果我+1和有4个输出层,结果是在95%的范围。

我添加了一个额外的类的图像到我的数据集(所以4类),并注意到同样的事情 - if输出层的数量与类的数量相同,那么结果是可怕的,如果它是相同的+1,那么它工作非常好。

  inner_product_param {
num_output:3
weight_filler {
type:xavier
}
bias_filler {
type:常数

有人知道为什么会这样吗?我注意到,当我使用模型时,我使用 C ++示例代码从我的测试集的图像,然后它会抱怨说,我已经告诉它有4个类目前,我只提供标签为3在我的标签文件。如果我发明一个标签并将其添加到文件,我可以让程序运行,但然后它只返回一个类的概率为1.0,无论我给它什么图像。


重要的是要注意,当微调和/或更改标签数量时,输入标签必须总是从0开始。

= < ,因为它们在计算损失时用作输出概率向量的索引。

因此,如果您有

  inner_product_params {
num_output:3
}



如果您使用 num_output:3 无法表示标签3,并且实际上具有对应于未使用的标签0的冗余线。

正如您观察到的,当改变为 num_output:4 caffe再次能够表示标签3并且结果改进,但是在参数矩阵中仍然有一个未使用的行。


I've modified the Caffe MNIST example to classify 3 classes of image. One thing I noticed was that if I specify the number of output layers as 3, then my test accuracy drops horribly - down to the low 40% range. However, if I +1 and have 4 output layers, the result is in the 95% range.
I added an extra class of images to my dataset (so 4 classes) and noticed the same thing - if the number of output layers were the same as the number of classes, then the result was horrible, if it was the same +1, then it worked really well.

  inner_product_param {
    num_output: 3
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"

Does anyone know why this is? I've noticed that when I use the model I train with the C++ example code on an image from my test set then it will complain that I've told it that there are 4 classes present and I've only supplied labels for 3 in my labels file. If I invent a label and add it to the file, I can get the program to run, but then it just returns one of the classes with a probability of 1.0 no matter what image I give it.

解决方案

It is important to notice that when fine-tuning and/or changing the number of labels the input labels must always start from 0, as they are used as indices into the output probability vector when computing the loss.
Thus, if you have

 inner_product_params {
   num_output: 3
 }

You must have training labels 0,1 and 2 only.

If you use num_output: 3 with labels 1,2,3 caffe is unable to represent label 3 and in fact has a redundant line corresponding to label 0 that is left unused.
As you observed, when changing to num_output: 4 caffe is again able to represent label 3 and the results improved, but still you have an unused row in the parameters matrix.

这篇关于Caffe输出层数精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆