gpt4 book ai didi

machine-learning - caffe的prototxt错误,caffe.SolverParameter没有名为 "name"的字段

转载 作者:行者123 更新时间:2023-11-30 08:38:44 24 4
gpt4 key购买 nike

我使用 HDF5 编写了一个关于多标签分类的 caffe net,这是名为“auto_train.prototxt”的 prototxt 文件

name: "multilabel_net"
layer {
name: "data"
type: "HDF5Data"
top: "data"
top: "label"
include {
phase: TRAIN
}
hdf5_data_param {
source: "examples/corel5k/train.h5list"
batch_size: 50
shuffle: 1
}
}
layer {
name: "data"
type: "HDF5Data"
top: "data"
top: "label"
include {
phase: TEST
}
hdf5_data_param {
source: "examples/corel5k/test.h5list"
batch_size: 50
}
}
layer {
name: "conv1"
type: "Convolution"
bottom: "data"
top: "conv1"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 96
kernel_size: 11
stride: 4
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
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"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 256
pad: 2
kernel_size: 5
group: 2
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 1
}
}
}
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"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 384
pad: 1
kernel_size: 3
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 0
}
}
}
layer {
name: "relu3"
type: "ReLU"
bottom: "conv3"
top: "conv3"
}
layer {
name: "conv4"
type: "Convolution"
bottom: "conv3"
top: "conv4"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 384
pad: 1
kernel_size: 3
group: 2
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 1
}
}
}
layer {
name: "relu4"
type: "ReLU"
bottom: "conv4"
top: "conv4"
}
layer {
name: "conv5"
type: "Convolution"
bottom: "conv4"
top: "conv5"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
convolution_param {
num_output: 256
pad: 1
kernel_size: 3
group: 2
weight_filler {
type: "gaussian"
std: 0.01
}
bias_filler {
type: "constant"
value: 1
}
}
}
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"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 4096
weight_filler {
type: "gaussian"
std: 0.005
}
bias_filler {
type: "constant"
value: 1
}
}
}
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"
param {
lr_mult: 1
decay_mult: 1
}
param {
lr_mult: 2
decay_mult: 0
}
inner_product_param {
num_output: 4096
weight_filler {
type: "gaussian"
std: 0.005
}
bias_filler {
type: "constant"
value: 1
}
}
}
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: "score"
type: "InnerProduct"
bottom: "fc7"
top: "score"
inner_product_param {
num_output: 260
}
}
layer {
name: "loss"
type: "SigmoidCrossEntropyLoss"
bottom: "score"
bottom: "label"
top: "loss"
}
layer {
name: "score"
type: "InnerProduct"
bottom: "fc7"
top: "score"
inner_product_param {
num_output: 260
}
include {
phase: TEST}
}

这是 train.sh

 ./build/tools/caffe train \
-solver examples/corel5k/auto_train.prototxt \
-weights examples/corel5k/bvlc_reference_caffenet.caffemodel

但是当我运行这个脚本时,它出了问题

  [libprotobuf ERROR google/protobuf/text_format.cc:245] Error parsing text-format caffe.SolverParameter: 1:5: Message type "caffe.SolverParameter" has no field named "name".  
F0316 15:57:16.892113 3464 upgrade_proto.cpp:1063] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse SolverParameter file: examples/corel5k/auto_train.prototxt
*** Check failure stack trace: ***
@ 0x7f79b3a4011d google::LogMessage::Fail()
@ 0x7f79b3a41fbd google::LogMessage::SendToLog()
@ 0x7f79b3a3fd38 google::LogMessage::Flush()
@ 0x7f79b3a4281e google::LogMessageFatal::~LogMessageFatal()
@ 0x7f79b4065ee7 caffe::ReadSolverParamsFromTextFileOrDie()
@ 0x40a8c5 train()
@ 0x407544 main
@ 0x7f79b25a0ec5 (unknown)
@ 0x407615 (unknown)
Aborted (core dumped)

我不知道发生了什么,寻求帮助

最佳答案

您将网络结构定义 prototxt(又名 train_val.prototxt)与求解器定义 prototxt(又名 solver.prototxt)混淆了。

参见,例如AlexNet example对于这两个不同 prototxt 文件。

网络结构定义,train_val.prototxt定义网络结构,看起来像您编写的auto_train.prototxt文件。

但是,您缺少 solver definition prototxt , solver.prototxt 定义优化过程的元参数。
在您的情况下,solver.prototxt 看起来像:

net: "examples/corel5k/auto_train.prototxt" # here is where you put the net structure file
test_iter: 1000
test_interval: 1000
base_lr: 0.01
lr_policy: "step"
gamma: 0.1
stepsize: 100000
display: 20
max_iter: 450000
momentum: 0.9
weight_decay: 0.0005
snapshot: 10000
snapshot_prefix: "examples/corel5k/my_auto_snapshots"
solver_mode: GPU

您可以在 solver.protoxt here 中找到有关如何设置元参数的信息。和 here .

一旦你有了合适的solver.prototxt,你就可以运行caffe:

./build/tools/caffe train \
-solver examples/corel5k/solver.prototxt \
-weights examples/corel5k/bvlc_reference_caffenet.caffemodel

关于machine-learning - caffe的prototxt错误,caffe.SolverParameter没有名为 "name"的字段,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36030331/

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