Caffe中用训练好的模型测试,deploy文件的修改方法

训练好网络模型后,需要在测试集上验证模型分类的正确率,这时,就需要把训练的网络文件net.prototxt修改为deploy.prototxt,然后再进行测试。

输入数据层改动如下:

name: "SpecNet"
layer {
  name: "spectr"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    scale: 0.00390625
  }
  data_param {
    source: "../data/train"
    batch_size: 15
    backend: LMDB
  }
}
layer {
  name: "spectr"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  transform_param {
    scale: 0.00390625
  }
  data_param {
    source: "../data/valid"
    batch_size: 15
    backend: LMDB
  }
}

# Layer 1 128x128x1
layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 1
  }
  ...
  ...
  ...

改为:

name: "SpecNet"
layer {
  name: "data"
  type: "Input"
  top: "data"
  input_param { shape: { dim: 1 dim: 3 dim: 128 dim: 128 } }
}
# Layer 1 128x128x1
layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 1
  }
  ...
  ...
  ...

其中
dim: 1 #num,对待识别样本进行数据增广的数量,可自行定义。一般会进行5次crop,之后分别flip。如果该值为10则表示一个样本会变成10个,之后输入到网络进行识别。如果不进行数据增广,可以设置成1
dim: 3 #通道数,表示RGB三个通道
dim: 128 #图像的长和宽
input_param的参数解释:http://blog.csdn.net/u010417185/article/details/52619593

输出层改动如下:

# Classification Layer 6x1
layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "ip2"
  bottom: "label"
  top: "accuracy"
}
layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "ip2"
  bottom: "label"
  top: "loss"
}
...
...
...

改为:

# Classification Layer 6x1
#layer {
#  name: "accuracy"
#  type: "Accuracy"
# bottom: "ip2"
#  bottom: "label"
#  top: "accuracy"
#}
layer {
  name: "prob"
  type: "Softmax"
  bottom: "ip2"
 # bottom: "label"
  top: "prob"
}
...
...
...

只需要改输入数据层和输出层,其他的一般不用修改。
可以参考:
http://blog.csdn.net/l18930738887/article/details/54898016
http://blog.csdn.net/lanxuecc/article/details/52474476
http://blog.csdn.net/fx409494616/article/details/53008971

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值