【问题标题】:Caffe: euclidean loss error: Inputs must have the same dimensionsCaffe:欧几里得损失错误:输入必须具有相同的维度
【发布时间】:2018-11-20 00:41:27
【问题描述】:

我在 python 中使用 caffe。所以这是我的斑点形状:

data                        3072     3.07e+03    (1, 3, 32, 32)
conv2d1                    12544     1.25e+04    (1, 16, 28, 28)
maxPool1                    3136     3.14e+03    (1, 16, 14, 14)
fc1                           10     1.00e+01    (1, 10)
ampl                          10     1.00e+01    (1, 10)
-------------------------------- params: name,w,(b)
conv2d1                     1200     1.20e+03    (16, 3, 5, 5)    
fc1                        31360     3.14e+04    (10, 3136)

这是我在 proto.txt 文件中的最后两层:

...
layer {
  name: "ampl"
  type: "Softmax"
  bottom: "fc1"
  top: "ampl"
  softmax_param {
    axis: 1
  }
}
layer {
  name: "loss"
  type: "EuclideanLoss"
  bottom: "ampl"
  bottom: "label"
  top: "loss"
}

我得到这个错误:

euclidean_loss_layer.cpp:12] Check failed: bottom[0]->count(1) == bottom[1]->count(1) (10 vs. 1) Inputs must have the same dimension.

【问题讨论】:

    标签: neural-network caffe conv-neural-network pycaffe convolutional-neural-network


    【解决方案1】:

    你的错误是不言自明的:

    Inputs must have the same dimension
    

    您正在尝试在 "ampl""label" 之间计算 "EuclideanLoss"。为此,您必须"ampl""label" 成为具有相同数量元素的 blob(又名 count())。然而,"ampl" 似乎有 10 个元素,"label" 只有一个元素。

    【讨论】:

    • ampl 有 10 个元素,因为我有 10 个输出神经元(10 类),而 label 有 1 个元素,因为它是一个数字 [0-9](10 类)。我该怎么办?要更改哪一个以及如何更改?
    • @NimaHatami 那你为什么要使用"EuclideanLoss"?这种损失主要用于回归任务。听起来您正在尝试标记数据。为什么不使用"SoftmaxWithLoss"(即交叉熵目标)?
    • 感谢@Shai,我将其更改为 SoftmaxWithLoss,现在可以使用了!
    猜你喜欢
    • 2015-09-14
    • 2018-07-30
    • 2019-09-22
    • 2018-06-12
    • 2022-10-25
    • 2018-04-20
    • 2016-12-15
    • 2013-11-03
    • 2021-06-05
    相关资源
    最近更新 更多