在自己的数据集上微调Light CNN

本文档记录了在自定义数据集上微调Light CNN模型的过程中遇到的问题,包括数据预处理(灰度化)、网络结构定义、训练集与验证集划分以及训练过程中的错误。同时,作者寻求关于解决报错和模型压缩的方法。

遇到的坑

light cnn 加载的是灰度图,所以在 data 层要添加参数:

is_color:false
示例如下:

layer {
  name: "data"
  type: "ImageData"
  top: "data"
  top: "label"
  image_data_param{
      source: "/home/code/caffe-master/lightCNNFace/val.txt"
      batch_size: 20
      is_color:false
    }
  transform_param {
    scale: 0.00390625
    crop_size: 128
    mirror: false
  }
  include: { phase: TEST }
}
1.编写微调的网络结构lightcnn_train_test.prototxt
2.准备训练图像数据,分成训练集和验证集合
注意 要将图像灰度化
3.运行训练脚本文件
code/caffe-master/build/tools/caffe train \
    --solver=code/caffe-master/lightCNNFace/LCNN_solver.prototxt \
    --weights=code/caffe-master/lightCNNFace/LightenedCNN_B.caffemodel -gpu=0
4.微调时报错
  Cannot copy param 0 weights from layer 'conv1'; shape mismatch.  Source param shape is 96 1 5 5 (2400); target param shape is 96 3 5 5 (7200). To learn this layer's parameters from scratch rather than copying from a saved net, rename the layer
5.附 lightcnn_train_test.prototxt
有过微调light cnn的网友吗?求解决方案,另外 如何进一步减小模型大小?
name: "DeepFace_set003_net"

layer {
  name: "data"
  type:"ImageData"
  top: "data"
  top: "label"
  image_data_param{
      source: "/home/himon/code/caffe-master/lightCNNFace/train.txt"
      batch_size: 20
      shuffle: true
    }
  transform_param {
    scale: 0.00390625
    crop_size: 128
    mirror: true

  }
  include: { phase: TRAIN }
}

layer {
  name: "data"
  type: "ImageData"
  top: "data"
  top: "label"
  image_data_param{
      source: "/home/himon/code/caffe-master/lightCNNFace/val.txt"
      batch_size: 20
    }
  transform_param {
    scale: 0.00390625
    crop_size: 128
    mirror: false
  }
  include: { phase: TEST }
}

layer{
  name: "conv1"
  type: "Convolution"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  param {
    lr_mult: 2
    decay_mult: 0
  }
  convolution_param {
    num_output: 96
    kernel_size: 5
    stride: 1
    pad: 2
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
      value: 0.1
    }
  }
  bottom: "data"
  top: "conv1"
}

layer{
  name: "slice1"
  type:"Slice"
  slice_param {
    slice_dim: 
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值