使用自己的网络在Caffe上训练MNIST:消息类型”caffe.LayerParameter”没有名为”lr_mult”的字段

我在Caffe上编写了一个网络来训练MNIST数据集,但遇到了以下错误:
Message type "caffe.LayerParameter" has no field named "blogs_lr".
我在网上搜索了一下,有人告诉我将blogs_lr更改为lr_mult,因为前者是旧版本的。我做了更改,但错误仍然没有解决:

I0907 14:47:33.021236 23466 solver.cpp:81] Creating training net from train_net file: /home/pris/caffe-master/examples/mnist/my_lenet_train.prototxt[libprotobuf ERROR google/protobuf/text_format.cc:245] Error parsing text-format caffe.NetParameter: 22:10: Message type "caffe.LayerParameter" has no field named "lr_mult".F0907 14:47:33.021351 23466 upgrade_proto.cpp:79] Check failed: ReadProtoFromTextFile(param_file, param) Failed to parse NetParameter file: /home/pris/caffe-master/examples/mnist/my_lenet_train.prototxt*** Check failure stack trace: ***    @     0x7fc9b530bdaa  (unknown)    @     0x7fc9b530bce4  (unknown)    @     0x7fc9b530b6e6  (unknown)    @     0x7fc9b530e687  (unknown)    @     0x7fc9b591b19e  caffe::ReadNetParamsFromTextFileOrDie()    @     0x7fc9b59097e7  caffe::Solver<>::InitTrainNet()    @     0x7fc9b590a83c  caffe::Solver<>::Init()    @     0x7fc9b590ab6a  caffe::Solver<>::Solver()    @     0x7fc9b5a49663  caffe::Creator_SGDSolver<>()    @           0x40e9be  caffe::SolverRegistry<>::CreateSolver()    @           0x407b62  train()    @           0x4059ec  main    @     0x7fc9b4619f45  (unknown)    @           0x406121  (unknown)    @              (nil)  (unknown)Aborted (core dumped)

这是我定义的网络(my_lenet_train.prototxt):

name:"LeNet"layer{  name:"mnist"  type:"Data"  data_param  {    source:"/home/pris/caffe-master/examples/mnist/mnist_train_lmdb"    batch_size:64    scale:0.00390625  }  top:"data"  top:"label"}layer{  name:"conv1"  type:"Convolution"  bottom:"data"  top:"conv1"  lr_mult:1  lr_mult:2  convolution_param  {      num_output:20    kernel_size:5    stride:1    weight_filler  { type:"xavier" }    bias_filler {type:"constant" }  }}layer{  name:"pool1"  type:"Pooling"  bottom:"conv1"  top:"pool1"   pooling_param  {    pool:MAX    kernel_size:2    stride:2  }}layer{  name:"conv2"  type:"Convolution"  bottom:"pool1"  top:"conv2"  lr_mult:1  lr_mult:2  convolution_param  {      num_output:50    kernel_size:5    stride:1    weight_filler  { type:"xavier" }    bias_filler {type:"constant" }  }}layer{  name:"pool2"  type:"Pooling"  bottom:"conv2"  top:"pool2"   pooling_param  {    pool:MAX    kernel_size:2    stride:2  }}layer{  name:"ip1"  type:"InnerProduct"  lr_mult:1  lr_mult:2  inner_product_param  {    num_output:500    weight_filler {type:"xavier"}    bias_filler {type:"constant" }  }  bottom:"pool2"  top:"ip1"}layer{  name:"relu1"  type:"ReLU"  bottom:"ip1"  top:"ip1"}layer{  name:"ip2"  type:"InnerProduct"  lr_mult:1  lr_mult:2  inner_product_param  {    num_output:10    weight_filler {type:"xavier"}    bias_filler {type:"constant" }  }  bottom:"ip1"  top:"ip2"}layer{ name:"loss" type:"SoftmaxWithLoss" bottom:"ip2" bottom:"label"}}

my_lenet_solver.prototxt:

train_net:"/home/pris/caffe-master/examples/mnist/my_lenet_train.prototxt"test_net:"/home/pris/caffe-master/examples/mnist/lenet_train_test.prototxt"test_iter:100test_interval:500base_lr:0.01momentum:0.9weight_decay:0.0005lr_policy:"inv"gamma:0.0001power:0.75display:100max_iter:10000snapshot:5000snapshot_prefix:"/home/pris/caffe-master/examples/mnist/lenet"solver_mode:1

train_lenet.sh:

#!/usr/bin/env shTOOLS=/home/pris/caffe-master/build/tools$TOOLS/caffe train \  --solver=/home/pris/caffe-master/examples/mnist/my_lenet_solver.prototxt

顺便提一下,我之前用imagenet训练过自己的数据集(就像这里的例子:使用Caffe训练我自己的JPG数据集:类型”caffe.ImageDataParameter”没有名为”backend”的字段,网络定义中也有变量‘lr_mult’,但我运行时从未遇到过这个错误。我真的很想知道为什么。我的电脑上只有一个版本的Caffe。


回答:

‘lr_mult’参数必须放在‘param’标签内。请查看这里

layer {  name: "conv1"  type: "Convolution"  param { lr_mult: 1 }  param { lr_mult: 2 }  convolution_param {    num_output: 20    kernel_size: 5    stride: 1    weight_filler {      type: "xavier"    }    bias_filler {      type: "constant"    }  }  bottom: "data"  top: "conv1"}

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注