C++ Caffe ImageData神经网络基本示例无法解析模型文件

C++ Caffe ImageData神经网络基本示例无法解析模型文件,c++,neural-network,deep-learning,caffe,C++,Neural Network,Deep Learning,Caffe,我正在尝试用我使用caffe库从CSV文件准备的图像数据构建一个神经网络的最小示例 我的原文如下:[wine\u train.prototxt] name:"wineclass" layers { name: "data" type: "IMAGEDATA" top: "data" top: "label" image_data_param { source: "examples/wine/test.txt" batch_size: 10 }

我正在尝试用我使用caffe库从CSV文件准备的图像数据构建一个神经网络的最小示例

我的原文如下:[wine\u train.prototxt]

name:"wineclass"
layers {    
  name: "data"
  type: "IMAGEDATA"
  top: "data"
  top: "label"
  image_data_param {
    source: "examples/wine/test.txt"
    batch_size: 10
  }
  include{
   phase:TEST
  }
}
layer {
  name: "data"
  type: "IMAGEDATA"
  top: "label"
  top: "label"
  image_data_param {
    source: "examples/wine/train.txt"
    batch_size: 2
  }
  include{
   phase:TRAIN
  }
}
layers {
  name: "ip"
  type: "INNER_PRODUCT"
  bottom: "data"
  top: "ip"
  inner_product_param {
    num_output: 3
  }
}
layers {
  name: "loss"
  type: "SOFTMAX_LOSS"
  bottom: "ip"
  bottom: "label"
  top: "loss"
}
layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "ip"
  bottom: "label"
  top: "accuracy"
  include {
    phase: TEST
  }
}
我的解算器如下所示:

net: "examples/wine/wine_train.prototxt"
test_iter: 250
test_interval: 1000
base_lr: 0.01
lr_policy: "step"
gamma: 0.1
stepsize: 5000
display: 1000
max_iter: 10000
momentum: 0.9
weight_decay: 0.0005
snapshot: 10000
snapshot_prefix: "wine/train"
solver_mode: CPU
每次出现以下错误时:

LIGH@IVIP2:~/caffe$ build/tools/caffe train -model '/home/shaunak/caffe/examples/wine/wine_train.prototxt' -solver '/home/shaunak/caffe/examples/wine/solver.prototxt'
I0415 04:31:00.154145 57047 caffe.cpp:117] Use CPU.
I0415 04:31:00.154485 57047 caffe.cpp:121] Starting Optimization
I0415 04:31:00.154552 57047 solver.cpp:32] Initializing solver from parameters:
test_iter: 250
test_interval: 1000
base_lr: 0.01
display: 1000
max_iter: 10000
lr_policy: "step"
gamma: 0.1
momentum: 0.9
weight_decay: 0.0005
stepsize: 5000
snapshot: 10000
snapshot_prefix: "wine/train"
solver_mode: CPU
net: "examples/wine/wine_train.prototxt"
I0415 04:31:00.154660 57047 solver.cpp:79] Creating training net from net file: examples/wine/wine_train.prototxt
[libprotobuf ERROR google/protobuf/text_format.cc:245] Error parsing text-format caffe.NetParameter: 4:9: Expected integer or identifier.
F0415 04:31:00.154774 57047 upgrade_proto.cpp:928] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: examples/wine/wine_train.prototxt
*** Check failure stack trace: ***
    @     0x7f4a30766c3c  google::LogMessage::Fail()
    @     0x7f4a30766b88  google::LogMessage::SendToLog()
    @     0x7f4a3076658a  google::LogMessage::Flush()
    @     0x7f4a30769521  google::LogMessageFatal::~LogMessageFatal()
    @     0x7f4a30b8b1ee  caffe::ReadNetParamsFromTextFileOrDie()
    @     0x7f4a30b6dfa2  caffe::Solver<>::InitTrainNet()
    @     0x7f4a30b6ee63  caffe::Solver<>::Init()
    @     0x7f4a30b6f036  caffe::Solver<>::Solver()
    @           0x40c3c0  caffe::GetSolver<>()
    @           0x406361  train()
    @           0x4048f1  main
    @     0x7f4a2fe86ec5  (unknown)
    @           0x404e9d  (unknown)
Aborted (core dumped)
LIGH@IVIP2:~/caffe$
LIGH@IVIP2:~/caffe$build/tools/caffe train-model'/home/shaunak/caffe/examples/wine/wine\u train.prototxt'-solver'/home/shaunak/caffe/examples/wine/solver.prototxt'
I0415 04:31:00.154145 57047 caffe.cpp:117]使用CPU。
I0415 04:31:00.154485 57047 caffe.cpp:121]启动优化
I0415 04:31:00.154552 57047解算器。cpp:32]从参数初始化解算器:
试验堆:250
测试间隔:1000
基准线:0.01
显示器:1000
最高温度:10000
lr_政策:“步骤”
伽马:0.1
动量:0.9
重量衰减:0.0005
步长:5000
快照:10000
快照_前缀:“葡萄酒/火车”
解算器模式:CPU
net:“examples/wine/wine\u train.prototxt”
I0415 04:31:00.154660 57047 solver.cpp:79]从网络文件创建训练网络:examples/wine/wine_train.prototxt
[libprotobuf ERROR google/protobuf/text_format.cc:245]分析文本格式caffe时出错。NetParameter:4:9:应为整数或标识符。
F0415 04:31:00.154774 57047 upgrade_proto.cpp:928]检查失败:ReadProtoFromTextFile(param_file,param)无法解析NetParameter文件:examples/wine/wine_train.prototxt
***检查故障堆栈跟踪:***
@0x7f4a30766c3c谷歌::日志消息::失败()
@0x7f4a30766b88 google::LogMessage::SendToLog()
@0x7f4a3076658a google::LogMessage::Flush()
@0x7f4a30769521谷歌::LogMessageFatal::~LogMessageFatal()
@0x7F4A30B8B1E caffe::ReadNetParamsFromTextFileOrDie()
@0x7f4a30b6dfa2 caffe::解算器::InitTrainNet()
@0x7f4a30b6ee63 caffe::解算器::初始化()
@0x7f4a30b6f036 caffe::解算器::解算器()
@0x40c3c0 caffe::GetSolver()
@0x406361列车()
@0x4048f1主
@0x7f4a2fe86ec5(未知)
@0x404e9d(未知)
中止(堆芯转储)
LIGH@IVIP2:~/caffe$

错误具体说明了什么以及如何解决它?

您的
'wine\u train.prototxt'
格式有问题。它混合了旧格式(即,
而不是
,层类型使用所有大写字母)和新格式(即层类型作为字符串而不是枚举)。
从图层类型中删除引号(
),然后运行
$CAFFE\u ROOT/build/tools/upgrade\u net\u proto\u text.bin
以获取升级后的net prototxt

此外,在运行
caffe train
时,您不需要(也可能不应该)提供
-model
参数。此参数在运行
caffe测试时使用。模型文件在
solver.prototxt
中定义