gpt4 book ai didi

c++ - 形状不匹配,同时从 caffe 中自己训练的网络复制权重

转载 作者:太空宇宙 更新时间:2023-11-04 13:13:55 24 4
gpt4 key购买 nike

当我尝试在 C++ 中加载经过训练的网络时,我在 FC 层上遇到形状不匹配错误。我在 TRAIN/TEST 阶段的输入层(仅在源和批量大小上有所不同,省略了一些参数):

layer {
type: "ImageData"
image_data_param {
batch_size: 8
new_height: 256
new_width: 256
}
transform_param {
crop_size: 227
}
}

用于部署的输入层:

layer {
type: "Input"
input_param { shape: { dim: 1 dim: 3 dim: 256 dim: 256 }}
}

错误:

Cannot copy param 0 weights from layer 'fc4'; shape mismatch. Source param shape is 8 26912 (215296); target param shape is 8 32768 (262144).

我找到了 this答案,但我自己的模型已经过训练和测试。你能解释一下吗?

最佳答案

您正在为您的网络提供不同大小的输入:在训练期间,您将输入裁剪为 227x277,而在测试期间,您不裁剪并将图像保留为 256x256。这会导致您遇到错误。

关于c++ - 形状不匹配,同时从 caffe 中自己训练的网络复制权重,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38393939/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com