【发布时间】:2016-07-07 00:24:00
【问题描述】:
我正在尝试建立 caffe 的 infogain loss 层来工作。我已经看过帖子,解决方案,但对我来说它仍然不起作用
我的数据 lmdb 尺寸是 Nx1xHxW(灰度图像),我的目标图像 lmdb 尺寸是 Nx3xH/8xW/8(rgb 图像)。我最后一个卷积层的尺寸是 1x3x20x80。 output_size 为 3, 所以我有 3 个类,因为我的标签编号在目标 lmdb 图像数据集中是 (0,1,2)。
我想试试 infogain loss layer,因为我觉得我有类不平衡的问题。我的大部分图片都包含太多背景。
在我的最后一个卷积层 (conv3) 之后,我有这些:
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"
}
}
我的信息增益矩阵是由InfogainLoss layer 帖子生成的(正如 Shai 建议的那样),所以我的 H 矩阵是 1x1x3x3 维度(一个单位矩阵)。所以我的L 是 3,因为我有 3 个班级。
当我运行 prototxt 文件时,一切都很好(尺寸还可以),但是在我的最后一个卷积层(conv3 层)之后,我收到以下错误:
I0320 14:42:16.722874 5591 net.cpp:157] Top shape: 1 3 20 80 (4800) I0320 14:42:16.722882 5591 net.cpp:165] Memory required for data: 2892800 I0320 14:42:16.722892 5591 layer_factory.hpp:77] Creating layer loss I0320 14:42:16.722900 5591 net.cpp:106] Creating Layer loss I0320 14:42:16.722906 5591 net.cpp:454] loss <- conv3 I0320 14:42:16.722913 5591 net.cpp:411] loss -> loss F0320 14:42:16.722928 5591 layer.hpp:374] Check failed: ExactNumBottomBlobs() == bottom.size() (2 vs. 1) SoftmaxWithLoss Layer takes 2 bottom blob(s) as input.
我仔细检查过,每个 lmdb 数据集文件名都已正确设置。我不知道可能是什么问题。有什么想法吗?
亲爱的@Shai
感谢您的回答。正如你所说,我做了以下事情:
layer {
name: "prob"
type: "Softmax"
bottom: "conv3"
top: "prob"
softmax_param { axis: 1 }
}
layer {
bottom: "prob"
bottom: "label"
top: "infoGainLoss"
name: "infoGainLoss"
type: "InfogainLoss"
infogain_loss_param {
source: "infogainH.binaryproto"
}
}
但我仍然有错误:
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)
【问题讨论】:
标签: machine-learning computer-vision neural-network deep-learning caffe