遇到的坑
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: 1
}
bottom: &#