我使用HDF5编写了有关多标签分类的Caffe网络,这是一个名为'auto_train.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)



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

最佳答案

您将网络结构定义原型(也称为train_val.prototxt)与求解器定义原型(也称为solver.prototxt)混淆了。

有关这两个不同的prototxt文件,请参见例如AlexNet example

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

但是,您缺少为优化过程定义元参数的solver definition prototxtsolver.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 herehere中找到有关如何设置元参数的信息。

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

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

07-24 09:52