【问题标题】:[Caffe]: Check failed: ShapeEquals(proto) shape mismatch (reshape not set)[Caffe]:检查失败:ShapeEquals(proto) 形状不匹配(未设置重塑)
【发布时间】:2015-08-26 00:08:36
【问题描述】:

我有这个错误,我试图在互联网上看一下,但我没有弄清楚。

我使用 Caffe 成功训练了我的网络,准确率约为 82%。

现在我正在尝试通过此代码使用图像进行尝试:

python python/classify.py --model_def examples/imagenet/imagenet_deploy.prototxt --pretrained_model caffe_mycaffe_train_iter_10000.caffemodel --images_dim 64,64 data/mycaffe/testingset/cat1/113.png foo --mean_file data/mycaffe/mycaffe_train_mean.binaryproto

是的,我的图像是 64x64,

这些是我得到的最后几行:

I0610 15:33:44.868100 28657 net.cpp:194] conv3 不需要反向计算。 I0610 15:33:44.868110 28657 net.cpp:194] norm2 不需要反向计算。 I0610 15:33:44.868120 28657 net.cpp:194] pool2 不需要反向计算。 I0610 15:33:44.868130 28657 net.cpp:194] relu2 不需要反向计算。 I0610 15:33:44.868142 28657 net.cpp:194] conv2 不需要反向计算。 I0610 15:33:44.868152 28657 net.cpp:194] norm1 不需要反向计算。 I0610 15:33:44.868162 28657 net.cpp:194] pool1 不需要反向计算。 I0610 15:33:44.868173 28657 net.cpp:194] relu1 不需要反向计算。 I0610 15:33:44.868182 28657 net.cpp:194] conv1 不需要反向计算。 I0610 15:33:44.868192 28657 net.cpp:235] 这个网络产生输出 fc8_pascal I0610 15:33:44.868214 28657 net.cpp:482] 收集学习率和权重衰减。 I0610 15:33:44.868238 28657 net.cpp:247] 网络初始化完成。 I0610 15:33:44.868249 28657 net.cpp:248] 数据所需的内存:3136120 F0610 15:33:45.025965 28657 blob.cpp:458] 检查失败:ShapeEquals(proto) 形状不匹配(未设置重塑) * 检查失败堆栈跟踪:* 中止(核心转储)

我试图不设置 --mean_file 和更多的东西,但我的镜头已经结束了。

这是我的 imagenet_deploy.prototxt,我已经修改了一些参数以进行调试,但没有任何效果。

name: "MyCaffe"
input: "data"
input_dim: 10
input_dim: 3
input_dim: 64
input_dim: 64
layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  convolution_param {
    num_output: 64
    kernel_size: 11
    stride: 4
  }
}
layer {
  name: "relu1"
  type: "ReLU"
  bottom: "conv1"
  top: "conv1"
}
layer {
  name: "pool1"
  type: "Pooling"
  bottom: "conv1"
  top: "pool1"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "norm1"
  type: "LRN"
  bottom: "pool1"
  top: "norm1"
  lrn_param {
    local_size: 5
    alpha: 0.0001
    beta: 0.75
  }
}
layer {
  name: "conv2"
  type: "Convolution"
  bottom: "norm1"
  top: "conv2"
  convolution_param {
    num_output: 64 
    pad: 2
    kernel_size: 5
    group: 2
  }
}
layer {
  name: "relu2"
  type: "ReLU"
  bottom: "conv2"
  top: "conv2"
}
layer {
  name: "pool2"
  type: "Pooling"
  bottom: "conv2"
  top: "pool2"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "norm2"
  type: "LRN"
  bottom: "pool2"
  top: "norm2"
  lrn_param {
    local_size: 5
    alpha: 0.0001
    beta: 0.75
  }
}
layer {
  name: "conv3"
  type: "Convolution"
  bottom: "norm2"
  top: "conv3"
  convolution_param {
    num_output: 384
    pad: 1
    kernel_size: 3
  }
}
layer {
  name: "relu3"
  type: "ReLU"
  bottom: "conv3"
  top: "conv3"
}
layer {
  name: "conv4"
  type: "Convolution"
  bottom: "conv3"
  top: "conv4"
  convolution_param {
    num_output: 384
    pad: 1
    kernel_size: 3
    group: 2
  }
}
layer {
  name: "relu4"
  type: "ReLU"
  bottom: "conv4"
  top: "conv4"
}
layer {
  name: "conv5"
  type: "Convolution"
  bottom: "conv4"
  top: "conv5"
  convolution_param {
    num_output: 64
    pad: 1
    kernel_size: 3
    group: 2
  }
}
layer {
  name: "relu5"
  type: "ReLU"
  bottom: "conv5"
  top: "conv5"
}
layer {
  name: "pool5"
  type: "Pooling"
  bottom: "conv5"
  top: "pool5"
  pooling_param {
    pool: MAX
    kernel_size: 3
    stride: 2
  }
}
layer {
  name: "fc6"
  type: "InnerProduct"
  bottom: "pool5"
  top: "fc6"
  inner_product_param {
    num_output: 4096
  }
}
layer {
  name: "relu6"
  type: "ReLU"
  bottom: "fc6"
  top: "fc6"
}
layer {
  name: "drop6"
  type: "Dropout"
  bottom: "fc6"
  top: "fc6"
  dropout_param {
    dropout_ratio: 0.5
  }
}
layer {
  name: "fc7"
  type: "InnerProduct"
  bottom: "fc6"
  top: "fc7"
  inner_product_param {
    num_output: 4096
  }
}
layer {
  name: "relu7"
  type: "ReLU"
  bottom: "fc7"
  top: "fc7"
}
layer {
  name: "drop7"
  type: "Dropout"
  bottom: "fc7"
  top: "fc7"
  dropout_param {
    dropout_ratio: 0.5
  }
}
layer {
  name: "fc8_pascal"
  type: "InnerProduct"
  bottom: "fc7"
  top: "fc8_pascal"
  inner_product_param {
    num_output: 3
  }
}

谁能给我一个线索? 非常感谢。


C++ 和它们提供的分类箱也是如此:

F0610 18:06:14.975601 7906 blob.cpp:455] 检查失败:ShapeEquals(proto) 形状不匹配(未设置整形) * 检查失败堆栈跟踪:* @ 0x7f0e3c50761c google::LogMessage::Fail() @ 0x7f0e3c507568 谷歌::LogMessage::SendToLog() @ 0x7f0e3c506f6a google::LogMessage::Flush() @ 0x7f0e3c509f01 谷歌::LogMessageFatal::~LogMessageFatal() @ 0x7f0e3c964a80 caffe::Blob::FromProto() @ 0x7f0e3c89576e caffe::Net::CopyTrainedLayersFrom() @ 0x7f0e3c8a10d2 caffe::Net::CopyTrainedLayersFrom() @ 0x406c32 分类器::分类器() @ 0x403d2b 主要 @ 0x7f0e3b124ec5(未知) @ 0x4041ce(未知) 中止(核心转储)

【问题讨论】:

    标签: python c++ deep-learning caffe


    【解决方案1】:

    在我的例子中,我的求解器文件中第二个卷积层的内核大小与训练文件中的不同。更改求解器文件中的大小解决了问题。

    【讨论】:

      【解决方案2】:

      我刚刚遇到了同样的错误。在我的情况下,我最后一层的输出参数不正确:切换数据集,我更改了 train.prototxt 中的类数,但在 test.prototxt(或 deploy.prototxt)中没有这样做。纠正这个错误为我解决了问题。

      【讨论】:

        【解决方案3】:

        让我确认一下基本步骤是否正确。

        input_dim: 10
        input_dim: 3
        input_dim: 64
        input_dim: 64
        

        您是否尝试将第一个参数更改为 1,因为您只传递了一个图像。

        当顶部或底部 blob 的尺寸不正确时,会发生上述错误。除了输入 blob 之外,没有其他地方会出错。

        编辑 2:

        fromproto function call 的“reshape”参数设置为 false 时出现ShapeEquals(proto) shape mismatch (reshape not set) 错误消息。

        我在库中快速搜索了 fromproto 函数调用,如 here 所示。除了“CopyTrainedLayersFrom”函数之外,没有其他函数实际上将上述参数设置为false

        这实际上令人困惑。我建议的两种方法是:

        1. 检查caffe源代码是否从仓库更新。
        2. 尝试运行 /build/tools/ 中的 caffe.bin 可执行文件的 test 部分。

        【讨论】:

        • 一开始我改成了2。我将尝试创建整个网络并使用 input_dim: 10 对其进行 10.000 次迭代训练,并将再次尝试这样做。一会儿告诉你
        • 将其更改为 1,它应该可以在没有任何培训的情况下工作。第一个维度是批量大小,它与您所做的训练无关。
        • 我在 val.prototxt 和 train.prototxt 上有 "batch_size: 2" .... 我应该将其设置为 1 是否正确?
        • @Annop-K-Prabhu 发生同样的错误,1、2 或 10
        • 批量大小是为了利用多核。它对您的训练结果没有其他影响。请检查编辑后的答案。
        猜你喜欢
        • 2016-09-09
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2016-03-28
        • 2017-07-26
        • 2016-01-23
        相关资源
        最近更新 更多