【发布时间】:2017-03-29 04:13:06
【问题描述】:
我有一个fully connected layer 和一个SoftmaxWithLoss 层。我想要做的是以3D 而不是1D 的形式检索数据。
我的输入 ground_truth 图像是 3x128x128,我的最后一层看起来像这样:
layer {
name: "fc1"
type: "InnerProduct"
bottom: "conv"
top: "fc1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 49152 # 128 x 128 x 3
...
}
}
layer {
name: "result"
type: "SoftmaxWithLoss"
bottom: "fc1"
bottom: "label"
top: "result"
}
在这里我收到以下错误:
softmax_loss_layer.cpp:47] 检查失败:outer_num_ * inner_num_ == bottom[1]->count() (1 vs. 49152) 标签数必须与 预测;例如,如果 softmax 轴 == 1 且预测形状为 (N, C, H, W),标签计数(标签数量)必须为NHW,带整数 {0, 1, ..., C-1} 中的值。
这里有什么问题?我的标签是 3x128x128,我的 output_num 是 49152 = 3 x 128 x128??
我的后续问题是如何将这些 1D 数据转换为 3D 数据:
我正在为 caffe 使用 python API。我知道我“只是”必须将 1D 矢量重塑为 3D 矢量。但是我怎么知道在哪里“重塑”,因为 1D 矢量中的哪个位置对应于 3D 矢量中的位置。谁能帮我?
提前致谢!
【问题讨论】:
标签: python deep-learning caffe pycaffe