Machine learning 无信息层blobs故障
我正试图建立caffe的信息增益-损失层来工作。我看过帖子,解决方案,但对我来说仍然不起作用 我的数据lmdb尺寸为Nx1xHxW(灰度图像),我的目标图像lmdb尺寸为Nx3xH/8xW/8(rgb图像)。我的最后一个卷积层的尺寸是1x3x20x80。输出_大小为3, 所以我有3个类,因为我的标签号在目标lmdb图像数据集中是(0,1,2) 我想试试infogain-loss层,因为我觉得我有类不平衡的问题。我的大多数图像包含太多的背景 在我的最后一个卷积层(conv3)之后,我有:Machine learning 无信息层blobs故障,machine-learning,computer-vision,neural-network,deep-learning,caffe,Machine Learning,Computer Vision,Neural Network,Deep Learning,Caffe,我正试图建立caffe的信息增益-损失层来工作。我看过帖子,解决方案,但对我来说仍然不起作用 我的数据lmdb尺寸为Nx1xHxW(灰度图像),我的目标图像lmdb尺寸为Nx3xH/8xW/8(rgb图像)。我的最后一个卷积层的尺寸是1x3x20x80。输出_大小为3, 所以我有3个类,因为我的标签号在目标lmdb图像数据集中是(0,1,2) 我想试试infogain-loss层,因为我觉得我有类不平衡的问题。我的大多数图像包含太多的背景 在我的最后一个卷积层(conv3)之后,我有: lay
layer {
name: "loss"
type: "SoftmaxWithLoss"
bottom: "conv3"
top: "loss"
}
layer {
bottom: "loss"
bottom: "label"
top: "infoGainLoss"
name: "infoGainLoss"
type: "InfogainLoss"
infogain_loss_param {
source: "infogainH.binaryproto"
}
}
我的infogain矩阵是由post生成的(正如Shai所建议的),所以我的H矩阵是1x1x3x3维(身份矩阵)。所以我的L
是3,因为我有3个类。
当我运行prototxt文件时,一切正常(尺寸正常),但在最后一个卷积层(conv3层)之后,我得到以下错误:
但我还是有错误:
Top shape: 1 3 20 80 (4800)
I0320 16:30:25.110862 6689 net.cpp:165] Memory required for data: 2912000
I0320 16:30:25.110867 6689 layer_factory.hpp:77] Creating layer infoGainLoss
I0320 16:30:25.110877 6689 net.cpp:106] Creating Layer infoGainLoss
I0320 16:30:25.110884 6689 net.cpp:454] infoGainLoss <- prob
I0320 16:30:25.110889 6689 net.cpp:454] infoGainLoss <- label
I0320 16:30:25.110896 6689 net.cpp:411] infoGainLoss -> infoGainLoss
F0320 16:30:25.110965 6689 infogain_loss_layer.cpp:35] Check failed: bottom[1]->height() == 1 (20 vs. 1)
顶部形状:123080(4800)
I0320 16:30:25.110862 6689 net.cpp:165]数据所需的内存:2912000
I0320 16:30:25.110867 6689层工厂。hpp:77]创建层信息无
I0320 16:30:25.110877 6689 net.cpp:106]正在创建层infoGainLoss
I0320 16:30:25.110884 6689 net.cpp:454]infoGainLoss height()==1(20对1)
出了什么问题?
您的错误来自“丢失”
层,而不是“InfogainLoss”
层:您将输出类概率的“Softmax”
层与输出(标量)丢失值的“SoftmaxWithLoss”
层混淆了
你该怎么办?
“loss”
层替换为“prob”
层,类型为“Softmax”
层:
layer {
name: "prob"
type: "Softmax" # NOT SoftmaxWithLoss
bottom: "conv3"
top: "prob"
softmax_param { axis: 1 } # compute prob along 2nd axis
}
“InfogainLoss”
层不支持此功能。您可能需要调整“InfogainLoss”
层,使其具有类似“SoftmaxWithLoss”
的功能,允许沿任意轴计算损失。更新:我在
BVLC/caffe
上创建了一个“升级”infogain-loss层。此升级版本支持“沿轴丢失”,就像您所追求的一样。此外,它使“Softmax”层变得冗余,因为它在内部计算概率(请参阅)。升级后的图层可按如下方式使用:
layer {
bottom: "conv3" # prob is computed internally
bottom: "label"
top: "infoGainLoss"
name: "infoGainLoss"
type: "InfogainLoss"
infogain_loss_param {
source: "infogainH.binaryproto"
axis: 1 # compute loss and probability along axis
}
}
我还有一个错误。我编辑了我的问题。我尝试不使用infogain层,只使用Softmax层,caffe正在给我写标签和概率。后者总是0.33333,所以它什么也学不到。至于标签,我几乎没有1,只有0和2,它们是我图片上的背景,这就是为什么我认为这可能是一个类不平衡problem@experimenter1.您现在从infogain层得到的错误是由于您定义的是每像素损失,而不是每图像损失。SoftmaxWithLoss支持此功能,但infogain不支持。2.看起来你有一个类不平衡的问题,你可能想调整infogain层来处理每像素的损失非常感谢你。我可以试试这个修改过的版本吗?我想我需要将代码从github粘贴到我的infogain\u loss\u layer.cpp和hpp。并使用此修改版本的文件重新编译caffe。我是否需要更改caffe文件中的其他内容,或者只需修改这两个文件?您可以:
git clonehttps://github.com/shaibagon/caffe.git -b upgrade_infogain
应该可以做到这一点。你可能想考虑“樱桃选择”这个承诺到你自己的仓库…我强烈建议您使用git工具进行此更改,而不是自行修改并复制文件。如果不破坏git流,跟踪更改和不断更新代码会更容易。
layer {
name: "prob"
type: "Softmax" # NOT SoftmaxWithLoss
bottom: "conv3"
top: "prob"
softmax_param { axis: 1 } # compute prob along 2nd axis
}
layer {
bottom: "conv3" # prob is computed internally
bottom: "label"
top: "infoGainLoss"
name: "infoGainLoss"
type: "InfogainLoss"
infogain_loss_param {
source: "infogainH.binaryproto"
axis: 1 # compute loss and probability along axis
}
}