caffe训练自己的数据集——2. 开始训练

一、配置文件

1. 网络结构

henet_car_train_test.prototxt

#name: "LeNet"
layer {
  name: "mnist"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    scale: 0.00390625
  }
  data_param {
    source: "/home/datasets/carPlate/train_test_labels/train_10"
    batch_size: 64
    backend: LMDB
  }
}
layer {
  name: "mnist"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  transform_param {
    scale: 0.00390625
  }
  data_param {
    source: "/home/datasets/carPlate/train_test_labels/val_G5"
    batch_size: 100
    backend: LMDB  
    }
}
layer {
  name: "conv1"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  convolution_param {
    num_output: 32
    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: "group0_block0_conv0"
  type: "Convolution"
  bottom: "pool1"
  top: "group0_block0_conv0"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  convolution_param {
    num_output: 32
    pad: 1
    kernel_size: 3
    stride: 1
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "group0_block0_conv0_bn"
  type: "BatchNorm"
  bottom: "group0_block0_conv0"
  top: "group0_block0_conv0"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "group0_block0_conv0_scale"
  type: "Scale"
  bottom: "group0_block0_conv0"
  top: "group0_block0_conv0"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "group0_block0_conv0_relu"
  type: "ReLU"
  bottom: "group0_block0_conv0"
  top: "group0_block0_conv0"
}
layer {
  name: "group0_block0_conv1"
  type: "Convolution"
  bottom: "group0_block0_conv0"
  top: "group0_block0_conv1"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  convolution_param {
    num_output: 32
    pad: 1
    kernel_size: 3
    stride: 1
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "group0_block0_conv1_bn"
  type: "BatchNorm"
  bottom: "group0_block0_conv1"
  top: "group0_block0_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "group0_block0_conv1_scale"
  type: "Scale"
  bottom: "group0_block0_conv1"
  top: "group0_block0_conv1"
  scale_param {
    bias_term: true
  }
}



layer {
  name: "group1_block0_conv0"
  type: "Convolution"
  bottom: "group0_block0_conv1"
  top: "group1_block0_conv0"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  convolution_param {
    num_output: 32
    pad: 1
    kernel_size: 3
    stride: 1
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "group1_block0_conv0_bn"
  type: "BatchNorm"
  bottom: "group1_block0_conv0"
  top: "group1_block0_conv0"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "group1_block0_conv0_scale"
  type: "Scale"
  bottom: "group1_block0_conv0"
  top: "group1_block0_conv0"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "group1_block0_conv0_relu"
  type: "ReLU"
  bottom: "group1_block0_conv0"
  top: "group1_block0_conv0"
}
layer {
  name: "group1_block0_conv1"
  type: "Convolution"
  bottom: "group1_block0_conv0"
  top: "group1_block0_conv1"
  param {
    lr_mult: 1
    decay_mult: 1
  }
  convolution_param {
    num_output: 32
    pad: 1
    kernel_size: 3
    stride: 1
    weight_filler {
      type: "msra"
    }
  }
}
layer {
  name: "group1_block0_conv1_bn"
  type: "BatchNorm"
  bottom: "group1_block0_conv1"
  top: "group1_block0_conv1"
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
  param {
    lr_mult: 0
    decay_mult: 0
  }
}
layer {
  name: "group1_block0_conv1_scale"
  type: "Scale"
  bottom: "group1_block0_conv1"
  top: "group1_block0_conv1"
  scale_param {
    bias_term: true
  }
}
layer {
  name: "group1_block0_sum"
  type: "Eltwise"
  bottom: "group0_block0_conv1"
  bottom: "group1_block0_conv1"
  top: "group1_block0_sum"
  eltwise_param {
    operation: SUM
  }
}
layer {
  name: "group0_block0_sum"
  type: "Eltwise"
  bottom: "group1_block0_sum"
  bottom: "pool1"
  top: "group0_block0_sum"
  eltwise_param {
    operation: SUM
  }
}




layer {
  name: "conv2"
  type: "Convolution"
  bottom: "group0_block0_sum"
  top: "conv2"
  param {
    lr_mult: 1
  }
  param {
    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"
  bottom: "pool2"
  top: "ip1"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 500
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "relu1"
  type: "ReLU"
  bottom: "ip1"
  top: "ip1"
}
layer {
  name: "ip2"
  type: "InnerProduct"
  bottom: "ip1"
  top: "ip2"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 10
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "ip2"
  bottom: "label"
  top: "accuracy"
  include {
    phase: TEST
  }
}
layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "ip2"
  bottom: "lab`}}}}}}}}
``
l"
  top: "loss"
}
_product_param {
    num_output: 10
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "ip2"
  bottom: "label"
  top: "accuracy"
  include {
    phase: TEST
  }
}
layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "ip2"
  bottom: "label"
  top: "loss"
}

2. 超参数

lenet_solver.prototxt

# The train/test net protocol buffer definition
net:  "henet_car_train_test.prototxt"
# test_iter specifies how many forward passes the test should carry out.
# In the case of MNIST, we have test batch size 100 and 100 test iterations,
# covering the full 10,000 testing images.
test_iter: 100
# Carry out testing every 500 training iterations.
test_interval: 500
# The base learning rate, momentum and the weight decay of the network.
base_lr: 0.001
momentum: 0.9
weight_decay: 0.0005
# The learning rate policy
lr_policy: "inv"
gamma: 0.0001
power: 0.75
# Display every 100 iterations
display: 100
# The maximum number of iterations
max_iter: 10000
# snapshot intermediate results
snapshot: 5000
snapshot_prefix: "/home/datasets/carPlate/train_test_labels/train_10/train_10"  #前一个train_10是制定路径,最后一个表示模型文件的前缀
# solver mode: CPU or 
GPU
solver_mode: GPU

二、开始训练

1. 训练并输出日志

1. 无预训练
/opt/caffe/build/tools/caffe train \
--solver=/home/datasets/carPlate/train_test_labels/henet_solver.prototxt 2>&1 | tee /home/datasets/carPlate/train_test_labels/train_10/train_10_henet_Res2order.log
2. 加载预训练模型
/opt/caffe/build/tools/caffe train \
--solver=/home/datasets/carPlate/train_test_labels/henet_solver.prototxt \
--weights=/home/datasets/carPlate/train_test_labels/train_10/train_10_iter_45000.caffemodel \
2>&1 | tee /home/datasets/carPlate/train_test_labels/train_30/train_30_henet_Res2order.log
3. 

2. 输出数值信息

/opt/caffe/tools/extra/parse_log.py \
/home/datasets/carPlate/train_test_labels/train_10/train_10_henet_Res2order.log \#前一个步骤保存的日志文件
/home/datasets/carPlate/train_test_labels/train_10/ \#数值信息的保存路径
#生成henet_Res2order.log.test 和henet_Res2order.log.train两个文件

3. 绘制loss&accuracy曲线

4.测试数据

/opt/caffe/build/tools/caffe test \
--model=/home/datasets/carPlate/train_test_labels/henet_car_train_test.prototxt \
--weights=/home/datasets/carPlate/train_test_labels/train_30/train_30_iter_45000.caffemodel \
2>&1 | tee /home/datasets/carPlate/train_test_labels/train_30/test_30_henet_Res2order.log

5. 失败记录

文件名0123共计
G174241256731481
G264239195711271
G363983166591397
G4244319011871750
G5136057615562979

a. 第一次:从头开始训练

1. 网络结构:caffe自带```lenet_car_train_test.prototx```
2. 超参数:上面的```lenet_solver.prototxt```
3. 训练数据:train_100 (100%的训练数据),总的数据说明参见前文。
4. 测试结果:train_100_lenet_iter_10000.caffemodel
5. 测试分析:G4可能因为黄牌比例较大,所以效果较差;single_2是白色车牌,效果较差;其余效果也未达到99%
G1(1481)G2(1271)G3(1397)G4(1750)G5(2979)single_0(蓝色3627)single_1(黄色539)single_2(白色66)single_3(非11258)
97.4342%98.741%98.7831%31.6571%91.0708%93.6035%96.846%56.0606%98.712%

b. 第二次:单独训练白色和黄色车牌

1. 网络结构:train_batch_size:128->64
2. 超参数:base_lr: 0.001->0.001,weight_decay: 0.0005->0.0005
3. 预训练模型:train_100_lenet_iter_10000.caffemodel 
4. 训练数据:train_100_yellow_white
5. 测试结果:白牌和黄牌效果确实提升了,但是蓝牌和非车牌很差了,应该是迭代次数过多。
G1(1481)G2(1271)G3(1397)G4(1750)G5(2979)single_0(蓝色3627)single_1(黄色539)single_2(白色66)single_3(非11258)
97.4342%98.741%98.7831%31.6571%91.0708%93.6035%96.846%56.0606%98.712%
————————————————————8.54701%99.6289%98.4848%21.3892%

c. 第三次:单独训练白色和黄色车牌

1. 网络结构:train_batch_size:128->64, 2个conv层的学习率设为0,ip3学习率缩小100倍:0.01,0.02,
2. 超参数:base_lr: 0.001->0.001,weight_decay: 0.0005->0.0005
3. 预训练模型:train_100_lenet_iter_10000.caffemodel (从第一次开始)
4. 训练数据:train_100_yellow_white
5. 测试结果:4类别单独测试效果都上了90%,尤其是白色从56.0606%提升到97.192%,但蓝色略有下降,怀疑主要是由于蓝色和非车牌的误判导致G4效果不理想
模型G1(1481)G2(1271)G3(1397)G4(1750)G5(2979)single_0(蓝色3627)single_1(黄色539)single_2(白色66)single_3(非11258)
train_100_lenet_iter_10000.caffemodel97.4342%98.741%98.7831%31.6571%91.0708%93.6035%96.846%56.0606%98.712%
non————————————————8.54701%99.6289%98.4848%21.3892%
train_100_lenet_yellow_white_iter_10.caffemodel97.4342%98.7411%98.8547%31.7143%91.0708%93.5484%97.2171%97.192%98.7209%

c. 第四次:单独训练蓝色车牌

1. 网络结构:train_batch_size:128->64, 2个conv层的学习率设为0,ip3学习率缩小100倍:0.01,0.02,
2. 超参数:base_lr: 0.001->0.001,weight_decay: 0.0005->0.0005
3. 预训练模型:train_100_lenet_iter_10000.caffemodel (从第一次开始)
4. 训练数据:train_100_blue_non500
5. 测试结果:白牌和黄牌效果确实提升了,但是蓝牌和非车牌很差了,应该是迭代次数过多。
模型G1(1481)G2(1271)G3(1397)G4(1750)G5(2979)single_0(蓝色3627)single_1(黄色539)single_2(白色66)single_3(非11258)
97.4342%98.741%98.7831%31.6571%91.0708%93.6035%96.846%56.0606%98.712%
non————————————————8.54701%99.6289%98.4848%
train_100_lenet_yellow_white_iter_10.caffemodel97.4342%98.7411%98.8547%31.7143%91.0708%93.5484%57.6994%57.5758%98.7209%
train_100_lenet_blue_non500_iter_100.caffemodel97.5017%98.4264%98.4968%31.8857%91.8765:%94.5409%86.6419%86.3636%97.8593%

结论:妈的数据集做错了,一定不能有文件夹为空!!!!!

6. Lenet重新训练

常用vim命令:

替换:
:%s/abc/def/g

1. 原始Lenet训练

1. 网络结构:train_batch_size=64
2. 超参数:base_lr: 0.0001,weight_decay: 0.0005->0.0005
3. 预训练模型:从零开始
4. 训练数据:train_100_all
5. 测试结果:这里只分为2类,每50000次进行重新训练(使用snapshot参数)。
模型G1(1481)G2(1271)G3(1397)G4(1750)G5(2979)single_0(蓝色3627)single_1(黄色539)single_2(白色66)single_3(非11258)
train_100_lenet_iter_50000.caffemodel98.7846%99.6066%99.3558%97.8286%96.811%97.9597%97.9592%87.8788%99.0584%
train_100_lenet_iter_100000.caffemodel99.1222%99.764%99.4273%98.3428%97.5495%98.4836%97.957%98.4848%99.165%
train_100_lenet_iter_150000.caffemodel99.122299.76499.4989%98.7429%97.784598.5663%98.1447%100%99.2627%
train_100_lenet_iter_150000.caffemodel99.189799.685399.4989%98.8571%97.784598.5387%98.3302%100%99.316%
# The train/test net protocol buffer definition
net: "lenet_train_test.prototxt"
# test_iter specifies how many forward passes the test should carry out.
# In the case of MNIST, we have test batch size 100 and 100 test iterations,
# covering the full 10,000 testing images.
test_iter: 100
# Carry out testing every 500 training iterations.
test_interval: 500
# The base learning rate, momentum and the weight decay of the network.
base_lr: 0.0001
momentum: 0.9
weight_decay: 0.0005
# The learning rate policy
lr_policy: "inv"
gamma: 0.0001
power: 0.75
# Display every 100 iterations
display: 100
# The maximum number of iterations
max_iter: 50000
# snapshot intermediate results
snapshot: 5000
snapshot_prefix: "/home/datasets/carPlate/train_test_2_class/train_100/train_100_lenet"
# solver mode: CPU or GPU
solver_mode: GPU

2. Lenet全连接层的裁剪

第一次
1. 网络结构:train_batch_size=64,修改ip1_400 ->ip1_400,对应的num_oputput 500 ->400, 
2. 超参数:base_lr: 0.0001,weight_decay: 0.0005->0.0005, max_iter:50000
3. 预训练模型:train_100_lenet_iter_200000.caffemodel(前一个小节得到的模型)
4. 训练数据:train_100_all
5. 测试结果:这里只分为2类,每50000次进行重新训练(使用snapshot参数)。越往后训练,对负样本的准确率越高,模型大小:1.05Mb
模型G1(1481)G2(1271)G3(1397)G4(1750)G5(2979)single_0(蓝色3627)single_1(黄色539)single_2(白色66)single_3(非11258)
train_100_lenet_iter_50000.caffemodel98.7846%99.6066%99.3558%97.8286%96.811%97.9597%97.9592%87.8788%99.0584%
train_100_lenet_iter_100000.caffemodel99.1222%99.764%99.4273%98.3428%97.5495%98.4836%97.957%98.4848%99.165%
train_100_lenet_iter_150000.caffemodel99.122299.76499.4989%98.7429%97.784598.5663%98.1447%100%99.2627%
train_100_lenet_iter_150000.caffemodel99.189799.685399.4989%98.8571%97.784598.5387%98.3302%100%99.316%
train_100_lenet_zip_0_iter_50000.caffemodel99.324899.685399.4273%98.8%97.683898.5112%98.3302%100%99.2095%
train_100_lenet_zip_0_iter_100000.caffemodel99.257399.527999.3558%98.87429%97.583198.3182%98.1447%100%99.2361%
第二次
1. 网络结构:train_batch_size=64,修改ip1_400 ->ip1_200,对应的num_oputput 400 ->200, 
2. 超参数:base_lr: 0.0001,weight_decay: 0.0005->0.0005, max_iter:100000
3. 预训练模型:train_100_lenet_iter_200000.caffemodel(前一个小节得到的模型)
4. 训练数据:train_100_all
5. 测试结果:这里只分为2类,每50000次进行重新训练(使用snapshot参数)。越往后训练,对负样本的准确率越高,模型大小349k
模型G1(1481)G2(1271)G3(1397)G4(1750)G5(2979)single_0(蓝色3627)single_1(黄色539)single_2(白色66)single_3(非11258)
train_100_lenet_iter_50000.caffemodel98.7846%99.6066%99.3558%97.8286%96.811%97.9597%97.9592%87.8788%99.0584%
train_100_lenet_iter_100000.caffemodel99.1222%99.764%99.4273%98.3428%97.5495%98.4836%97.957%98.4848%99.165%
train_100_lenet_iter_150000.caffemodel99.122299.76499.4989%98.7429%97.784598.5663%98.1447%100%99.2627%
train_100_lenet_iter_150000.caffemodel99.189799.685399.4989%98.8571%97.784598.5387%98.3302%100%99.316%
train_100_lenet_zip_0_iter_50000.caffemodel99.324899.685399.4273%98.8%97.683898.5112%98.3302%100%99.2095%
train_100_lenet_zip_0_iter_100000.caffemodel99.257399.527999.3558%98.87429%97.583198.3182%98.1447%100%99.2361%
train_100_lenet_zip_1_iter_50000.caffemodel98.987299.685399.4989%98.85719%97.717498.4836%98.3302%100%99.2095%
train_100_lenet_zip_1_iter_50000.caffemodel99.054799.606699.4273%98.97149%97.683898.456%98.3302%100%99.2272%
第三次
1. 网络结构:train_batch_size=64,修改ip1_200 ->ip1_50,对应的num_oputput 200 ->50, 
2. 超参数:base_lr: 0.0001,weight_decay: 0.0005->0.0005, max_iter:100000
3. 预训练模型:train_100_lenet_iter_200000.caffemodel(前一个小节得到的模型)
4. 训练数据:train_100_all
5. 测试结果:这里只分为2类。模型大小152k
模型G1(1481)G2(1271)G3(1397)G4(1750)G5(2979)single_0(蓝色3627)single_1(黄色539)single_2(白色66)single_3(非11258)
train_100_lenet_iter_50000.caffemodel98.7846%99.6066%99.3558%97.8286%96.811%97.9597%97.9592%87.8788%99.0584%
train_100_lenet_iter_100000.caffemodel99.1222%99.764%99.4273%98.3428%97.5495%98.4836%97.957%98.4848%99.165%
train_100_lenet_iter_150000.caffemodel99.122299.76499.4989%98.7429%97.784598.5663%98.1447%100%99.2627%
train_100_lenet_iter_150000.caffemodel99.189799.685399.4989%98.8571%97.784598.5387%98.3302%100%99.316%
train_100_lenet_zip_0_iter_50000.caffemodel99.324899.685399.4273%98.8%97.683898.5112%98.3302%100%99.2095%
train_100_lenet_zip_0_iter_100000.caffemodel99.257399.527999.3558%98.87429%97.583198.3182%98.1447%100%99.2361%
train_100_lenet_zip_1_iter_50000.caffemodel98.987299.685399.4989%98.85719%97.717498.4836%98.3302%100%99.2095%
train_100_lenet_zip_1_iter_100000.caffemodel99.054799.606699.4273%98.97149%97.683898.456%98.3302%100%99.2272%
train_100_lenet_zip_2_iter_60000.caffemodel99.324899.76499.4989%98.8%97.818198.6215%98.5158%100%99.2183%
train_100_lenet_zip_2_iter_100000.caffemodel99.189799.685399.4273%98.8%97.683898.4285%98.5158%100%99.1917%
第四次
1. 网络结构:train_batch_size=64,修改ip1_50 ->ip1_10,对应的num_oputput 50 ->10, 
2. 超参数:base_lr: 0.0001,weight_decay: 0.0005->0.0005, max_iter:100000
3. 预训练模型:train_100_lenet_iter_200000.caffemodel(前一个小节得到的模型)
4. 训练数据:train_100_all
5. 测试结果:这里只分为2类。模型大小126k
模型G1(1481)G2(1271)G3(1397)G4(1750)G5(2979)single_0(蓝色3627)single_1(黄色539)single_2(白色66)single_3(非11258)
train_100_lenet_iter_50000.caffemodel98.7846%99.6066%99.3558%97.8286%96.811%97.9597%97.9592%87.8788%99.0584%
train_100_lenet_iter_100000.caffemodel99.1222%99.764%99.4273%98.3428%97.5495%98.4836%97.957%98.4848%99.165%
train_100_lenet_iter_150000.caffemodel99.122299.76499.4989%98.7429%97.784598.5663%98.1447%100%99.2627%
train_100_lenet_iter_150000.caffemodel99.189799.685399.4989%98.8571%97.784598.5387%98.3302%100%99.316%
train_100_lenet_zip_0_iter_50000.caffemodel99.324899.685399.4273%98.8%97.683898.5112%98.3302%100%99.2095%
train_100_lenet_zip_0_iter_100000.caffemodel99.257399.527999.3558%98.87429%97.583198.3182%98.1447%100%99.2361%
train_100_lenet_zip_1_iter_50000.caffemodel98.987299.685399.4989%98.85719%97.717498.4836%98.3302%100%99.2095%
train_100_lenet_zip_1_iter_100000.caffemodel99.054799.606699.4273%98.97149%97.683898.456%98.3302%100%99.2272%
train_100_lenet_zip_2_iter_60000.caffemodel99.324899.76499.4989%98.8%97.818198.6215%98.5158%100%99.2183%
train_100_lenet_zip_2_iter_100000.caffemodel99.189799.685399.4273%98.8%97.683898.4285%98.5158%100%99.1917%
train_100_lenet_zip_3_iter_50000.caffemodel99.459899.76499.141%98.8571%98.086698.9247%98.3302%100%99.165%
train_100_lenet_zip_3_iter_50000.caffemodel99.324899.685399.3558%98.8571%97.885298.649%98.1447%100%99.245%
第五次
1. 网络结构:train_batch_size=64,修改ip1_10 ->ip1_4,对应的num_oputput 10 ->4, 
2. 超参数:base_lr: 0.0001,weight_decay: 0.0005->0.0005, max_iter:100000
3. 预训练模型:train_100_lenet_iter_200000.caffemodel(前一个小节得到的模型)
4. 训练数据:train_100_all
5. 测试结果:这里只分为2类。模型大小116k
模型G1(1481)G2(1271)G3(1397)G4(1750)G5(2979)single_0(蓝色3627)single_1(黄色539)single_2(白色66)single_3(非11258)
train_100_lenet_iter_50000.caffemodel98.7846%99.6066%99.3558%97.8286%96.811%97.9597%97.9592%87.8788%99.0584%
train_100_lenet_iter_100000.caffemodel99.1222%99.764%99.4273%98.3428%97.5495%98.4836%97.957%98.4848%99.165%
train_100_lenet_iter_150000.caffemodel99.122299.76499.4989%98.7429%97.784598.5663%98.1447%100%99.2627%
train_100_lenet_iter_150000.caffemodel99.189799.685399.4989%98.8571%97.784598.5387%98.3302%100%99.316%
train_100_lenet_zip_0_iter_50000.caffemodel99.324899.685399.4273%98.8%97.683898.5112%98.3302%100%99.2095%
train_100_lenet_zip_0_iter_100000.caffemodel99.257399.527999.3558%98.87429%97.583198.3182%98.1447%100%99.2361%
train_100_lenet_zip_1_iter_50000.caffemodel98.987299.685399.4989%98.85719%97.717498.4836%98.3302%100%99.2095%
train_100_lenet_zip_1_iter_100000.caffemodel99.054799.606699.4273%98.97149%97.683898.456%98.3302%100%99.2272%
train_100_lenet_zip_2_iter_60000.caffemodel99.324899.76499.4989%98.8%97.818198.6215%98.5158%100%99.2183%
train_100_lenet_zip_2_iter_100000.caffemodel99.189799.685399.4273%98.8%97.683898.4285%98.5158%100%99.1917%
train_100_lenet_zip_3_iter_50000.caffemodel99.459899.76499.141%98.8571%98.086698.9247%98.3302%100%99.165%
train_100_lenet_zip_3_iter_50000.caffemodel99.324899.685399.3558%98.8571%97.885298.649%98.1447%100%99.245%
train_100_lenet_zip_4_iter_50000.caffemodel99.189799.527998.9979%98.8571%98.355298.9799%98.1447%98.4848%99.1473%
train_100_lenet_zip_4_iter_100000.caffemodel99.392399.606699.0694%98.8571%98.120298.842%98.1447%100%99.2006 %
第五次
1. 网络结构:train_batch_size=64,修改ip1_4 ->ip1_2,对应的num_oputput 4 ->2,去掉最后一层全连接层 
2. 超参数:base_lr: 0.0001,weight_decay: 0.0005->0.0005, max_iter:100000
3. 预训练模型:train_100_lenet_iter_200000.caffemodel(前一个小节得到的模型)
4. 训练数据:train_100_all
5. 测试结果:至少需要两个全连接层。
模型G1(1481)G2(1271)G3(1397)G4(1750)G5(2979)single_0(蓝色3627)single_1(黄色539)single_2(白色66)single_3(非11258)
train_100_lenet_iter_50000.caffemodel98.7846%99.6066%99.3558%97.8286%96.811%97.9597%97.9592%87.8788%99.0584%
train_100_lenet_iter_100000.caffemodel99.1222%99.764%99.4273%98.3428%97.5495%98.4836%97.957%98.4848%99.165%
train_100_lenet_iter_150000.caffemodel99.122299.76499.4989%98.7429%97.784598.5663%98.1447%100%99.2627%
train_100_lenet_iter_150000.caffemodel99.189799.685399.4989%98.8571%97.784598.5387%98.3302%100%99.316%
train_100_lenet_zip_0_iter_50000.caffemodel99.324899.685399.4273%98.8%97.683898.5112%98.3302%100%99.2095%
train_100_lenet_zip_0_iter_100000.caffemodel99.257399.527999.3558%98.87429%97.583198.3182%98.1447%100%99.2361%
train_100_lenet_zip_1_iter_50000.caffemodel98.987299.685399.4989%98.85719%97.717498.4836%98.3302%100%99.2095%
train_100_lenet_zip_1_iter_100000.caffemodel99.054799.606699.4273%98.97149%97.683898.456%98.3302%100%99.2272%
train_100_lenet_zip_2_iter_60000.caffemodel99.324899.76499.4989%98.8%97.818198.6215%98.5158%100%99.2183%
train_100_lenet_zip_2_iter_100000.caffemodel99.189799.685399.4273%98.8%97.683898.4285%98.5158%100%99.1917%
train_100_lenet_zip_3_iter_50000.caffemodel99.459899.76499.141%98.8571%98.086698.9247%98.3302%100%99.165%
train_100_lenet_zip_3_iter_100000.caffemodel99.324899.685399.3558%98.8571%97.885298.649%98.1447%100%99.245%
train_100_lenet_zip_4_iter_50000.caffemodel99.189799.527998.9979%98.8571%98.355298.9799%98.1447%98.4848%99.1473%
train_100_lenet_zip_4_iter_100000.caffemodel99.392399.606699.0694%98.8571%98.120298.842%98.1447%100%99.2006 %
train_100_lenet_zip_5_iter_50000.caffemodel99.189799.527998.9979%98.8571%98.355298.9799%3.71058%98.4848%99.1473%
train_100_lenet_zip_5_iter_50000.caffemodel96.488996.538293.4145%80.9714%96.408298.9799%3.71058%96.9697%99.2006%

3. Lenet卷积层的裁剪

name: "LeNet"
layer {
  name: "mnist"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TRAIN
  }
  transform_param {
    scale: 0.00390625
  }
  data_param {
    source: "train_100_all"
    batch_size: 64
    backend: LMDB
  }
}
layer {
  name: "mnist"
  type: "Data"
  top: "data"
  top: "label"
  include {
    phase: TEST
  }
  transform_param {
    scale: 0.00390625
  }
  data_param {
    source: "val_G1"
    batch_size:1 
    backend: LMDB
  }
}
layer {
  name: "conv3"
  type: "Convolution"
  bottom: "data"
  top: "conv1"
  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"
    }
  }
}
layer {
  name: "pool1"
  type: "Pooling"
  bottom: "conv1"
  top: "pool1"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}
layer {
  name: "conv2_40"
  type: "Convolution"
  bottom: "pool1"
  top: "conv2"
  propagate_down:false
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  convolution_param {
    num_output: 40
    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_4_40"
  type: "InnerProduct"
  bottom: "pool2"
  top: "ip1"
  propagate_down:true
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 4
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "relu1"
  type: "ReLU"
  bottom: "ip1"
  top: "ip1"
}
layer {
  name: "ip3_4"
  type: "InnerProduct"
  bottom: "ip1"
  top: "ip2"
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 2
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}
layer {
  name: "accuracy"
  type: "Accuracy"
  bottom: "ip2"
  bottom: "label"
  top: "accuracy"
  include {
    phase: TEST
  }
}
layer {
  name: "loss"
  type: "SoftmaxWithLoss"
  bottom: "ip2"
  bottom: "label"
  top: "loss"
}
第6次
1. 网络结构:train_batch_size=64,修改ip1_10 ->ip1_4,对应的num_oputput 10 ->4, conv2:50->40, ip1到ip3的参数不变
2. 超参数:base_lr: 0.0001,weight_decay: 0.0005->0.0005, max_iter:100000,再增加到150000次(因为测试发现,对于白牌仍然存在提升空间)
3. 预训练模型:train_100_lenet_zip_4_iter_100000.caffemodel(前一个小节得到的模型)
4. 训练数据:train_100_all
5. 测试结果:这里只分为2类。模型大小102k
模型G1(1481)G2(1271)G3(1397)G4(1750)G5(2979)single_0(蓝色3627)single_1(黄色539)single_2(白色66)single_3(非11258)
train_100_lenet_zip_4_iter_50000.caffemodel99.189799.527998.9979%98.8571%98.355298.9799%98.1447%98.4848%99.1473%
train_100_lenet_zip_4_iter_100000.caffemodel99.392399.606699.0694%98.8571%98.120298.842%98.1447%100%99.2006 %
train_100_lenet_zip_6_iter_50000.caffemodel99.527399.527999.141%99.0286%97.952398.7869%99.0724%93.9394%99.1206%
train_100_lenet_zip_6_iter_100000.caffemodel99.527399.606699.3558%98.9143%98.05398.8144%98.8868%98.4848%99.165%
train_100_lenet_zip_6_iter_150000.caffemodel99.594999.685399.4273%99.0286%97.818198.6215%98.8868%98.4848%99.2983%
第7次
1. 网络结构:train_batch_size=64,修改ip1_10 ->ip1_4,对应的num_oputput 10 ->4, conv2:40->30, ip1到ip3的参数不变
2. 超参数:base_lr: 0.0001,weight_decay: 0.0005->0.0005, max_iter:100000,再增加到150000次(因为测试发现,对于白牌仍然存在提升空间)
3. 预训练模型:train_100_lenet_zip_4_iter_100000.caffemodel(前一个小节得到的模型)
4. 训练数据:train_100_all
5. 测试结果:这里只分为2类。模型大小79k
模型G1(1481)G2(1271)G3(1397)G4(1750)G5(2979)single_0(蓝色3627)single_1(黄色539)single_2(白色66)single_3(非11258)
train_100_lenet_zip_4_iter_50000.caffemodel99.189799.527998.9979%98.8571%98.355298.9799%98.1447%98.4848%99.1473%
train_100_lenet_zip_4_iter_100000.caffemodel99.392399.606699.0694%98.8571%98.120298.842%98.1447%100%99.2006 %
train_100_lenet_zip_6_iter_50000.caffemodel99.527399.527999.141%99.0286%97.952398.7869%99.0724%93.9394%99.1206%
train_100_lenet_zip_6_iter_100000.caffemodel99.527399.606699.3558%98.9143%98.05398.8144%98.8868%98.4848%99.165%
train_100_lenet_zip_6_iter_150000.caffemodel99.594999.685399.4273%99.0286%97.818198.6215%98.8868%98.4848%99.2983%
train_100_lenet_zip_7_iter_50000.caffemodel99.189799.685399.2126%98.5143%97.851698.7869%98.1447%93.9394%99.0762%
train_100_lenet_zip_7_iter_100000.caffemodel99.324899.685399.3558%98.6286%97.985998.8144%98.7013%95.4545%99.1384%
train_100_lenet_zip_7_iter_150000.caffemodel99.189799.606699.4989%98.9143%97.851698.4285%98.7013%93.9394%99.2983%
第8次
1. 网络结构:train_batch_size=64,修改ip1_10 ->ip1_4,对应的num_oputput 4 ->4, conv2:30->20, ip1到ip3的参数不变
2. 超参数:base_lr: 0.0001,weight_decay: 0.0005->0.0005, max_iter:100000,再增加到150000次(因为测试发现,对于白牌仍然存在提升空间)
3. 预训练模型:train_100_lenet_zip_4_iter_100000.caffemodel(前一个小节得到的模型)
4. 训练数据:train_100_all
5. 测试结果:这里只分为2类。模型大小54k
模型G1(1481)G2(1271)G3(1397)G4(1750)G5(2979)single_0(蓝色3627)single_1(黄色539)single_2(白色66)single_3(非11258)
train_100_lenet_zip_4_iter_50000.caffemodel99.189799.527998.9979%98.8571%98.355298.9799%98.1447%98.4848%99.1473%
train_100_lenet_zip_4_iter_100000.caffemodel99.392399.606699.0694%98.8571%98.120298.842%98.1447%100%99.2006 %
train_100_lenet_zip_6_iter_50000.caffemodel99.527399.527999.141%99.0286%97.952398.7869%99.0724%93.9394%99.1206%
train_100_lenet_zip_6_iter_100000.caffemodel99.527399.606699.3558%98.9143%98.05398.8144%98.8868%98.4848%99.165%
train_100_lenet_zip_6_iter_150000.caffemodel99.594999.685399.4273%99.0286%97.818198.6215%98.8868%98.4848%99.2983%
train_100_lenet_zip_7_iter_50000.caffemodel99.189799.685399.2126%98.5143%97.851698.7869%98.1447%93.9394%99.0762%
train_100_lenet_zip_7_iter_100000.caffemodel99.324899.685399.3558%98.6286%97.985998.8144%98.7013%95.4545%99.1384%
train_100_lenet_zip_7_iter_150000.caffemodel99.189799.606699.4989%98.9143%97.851698.4285%98.7013%93.9394%99.2983%
train_100_lenet_zip_8_iter_50000.caffemodel99.392399.370698.9979%98.7429%98.153798.9247%98.5158%93.9394%99.0496%
train_100_lenet_zip_8_iter_100000.caffemodel99.527399.606699.141%98.6286%98.153798.9523%98.5158%96.9697%99.0673%
train_100_lenet_zip_8_iter_150000.caffemodel99.459899.685399.4273%98.7429%97.952398.6766%98.3302%95.4545%99.2361%
第9次
1. 网络结构:train_batch_size=64,修改ip1_10 ->ip1_4,对应的num_oputput 4 ->4, conv2:20->15, 增加group=5(输入和输出channel数量必须能被group整除),ip1到ip3的参数不变
2. 超参数:base_lr: 0.0001,weight_decay: 0.0005->0.0005, max_iter:100000,再增加到150000次(因为测试发现,对于白牌仍然存在提升空间)
3. 预训练模型:train_100_lenet_zip_4_iter_100000.caffemodel(前一个小节得到的模型)
4. 训练数据:train_100_all
5. 测试结果:这里只分为2类。模型大小18k
模型G1(1481)G2(1271)G3(1397)G4(1750)G5(2979)single_0(蓝色3627)single_1(黄色539)single_2(白色66)single_3(非11258)
train_100_lenet_zip_4_iter_50000.caffemodel99.189799.527998.9979%98.8571%98.355298.9799%98.1447%98.4848%99.1473%
train_100_lenet_zip_4_iter_100000.caffemodel99.392399.606699.0694%98.8571%98.120298.842%98.1447%100%99.2006 %
train_100_lenet_zip_6_iter_50000.caffemodel99.527399.527999.141%99.0286%97.952398.7869%99.0724%93.9394%99.1206%
train_100_lenet_zip_6_iter_100000.caffemodel99.527399.606699.3558%98.9143%98.05398.8144%98.8868%98.4848%99.165%
train_100_lenet_zip_6_iter_150000.caffemodel99.594999.685399.4273%99.0286%97.818198.6215%98.8868%98.4848%99.2983%
train_100_lenet_zip_7_iter_50000.caffemodel99.189799.685399.2126%98.5143%97.851698.7869%98.1447%93.9394%99.0762%
train_100_lenet_zip_7_iter_100000.caffemodel99.324899.685399.3558%98.6286%97.985998.8144%98.7013%95.4545%99.1384%
train_100_lenet_zip_7_iter_150000.caffemodel99.189799.606699.4989%98.9143%97.851698.4285%98.7013%93.9394%99.2983%
train_100_lenet_zip_8_iter_50000.caffemodel99.392399.370698.9979%98.7429%98.153798.9247%98.5158%93.9394%99.0496%
train_100_lenet_zip_8_iter_100000.caffemodel99.527399.606699.141%98.6286%98.153798.9523%98.5158%96.9697%99.0673%
train_100_lenet_zip_8_iter_150000.caffemodel99.459899.685399.4273%98.7429%97.952398.6766%98.3302%95.4545%99.2361%
train_100_lenet_zip_9_iter_50000.caffemodel99.527399.370698.9263%98.5143%98.153798.9247%98.3302%98.4848%98.9696%
train_100_lenet_zip_9_iter_100000.caffemodel99.459899.449399.141%98.3429%97.784598.8972%97.9592%96.9697%98.9785%
train_100_lenet_zip_9_iter_150000.caffemodel99.392399.370699.2126%98.3429%97.717498.6766%97.5881%96.9697%99.1473%
第10次
1. 网络结构:train_batch_size=64,修改ip1_10 ->ip1_4,对应的num_oputput 4 ->4,conv1:20->15 conv2:20->15, 增加group=3(输入和输出channel数量必须能被group整除,记得更改conv1,conv2的name),ip1到ip3的参数不变
2. 超参数:base_lr: 0.0001,weight_decay: 0.0005->0.0005, max_iter:100000,再增加到150000次(因为测试发现,对于白牌仍然存在提升空间)
3. 预训练模型:train_100_lenet_zip_9_iter_100000.caffemodel(前一个小节得到的模型)
4. 训练数据:train_100_all
5. 测试结果:这里只分为2类。模型大小18k
模型G1(1481)G2(1271)G3(1397)G4(1750)G5(2979)single_0(蓝色3627)single_1(黄色539)single_2(白色66)single_3(非11258)
train_100_lenet_zip_4_iter_50000.caffemodel99.189799.527998.9979%98.8571%98.355298.9799%98.1447%98.4848%99.1473%
train_100_lenet_zip_4_iter_100000.caffemodel99.392399.606699.0694%98.8571%98.120298.842%98.1447%100%99.2006 %
train_100_lenet_zip_6_iter_50000.caffemodel99.527399.527999.141%99.0286%97.952398.7869%99.0724%93.9394%99.1206%
train_100_lenet_zip_6_iter_100000.caffemodel99.527399.606699.3558%98.9143%98.05398.8144%98.8868%98.4848%99.165%
train_100_lenet_zip_6_iter_150000.caffemodel99.594999.685399.4273%99.0286%97.818198.6215%98.8868%98.4848%99.2983%
train_100_lenet_zip_7_iter_50000.caffemodel99.189799.685399.2126%98.5143%97.851698.7869%98.1447%93.9394%99.0762%
train_100_lenet_zip_7_iter_100000.caffemodel99.324899.685399.3558%98.6286%97.985998.8144%98.7013%95.4545%99.1384%
train_100_lenet_zip_7_iter_150000.caffemodel99.189799.606699.4989%98.9143%97.851698.4285%98.7013%93.9394%99.2983%
train_100_lenet_zip_8_iter_50000.caffemodel99.392399.370698.9979%98.7429%98.153798.9247%98.5158%93.9394%99.0496%
train_100_lenet_zip_8_iter_100000.caffemodel99.527399.606699.141%98.6286%98.153798.9523%98.5158%96.9697%99.0673%
train_100_lenet_zip_8_iter_150000.caffemodel99.459899.685399.4273%98.7429%97.952398.6766%98.3302%95.4545%99.2361%
train_100_lenet_zip_9_iter_50000.caffemodel99.527399.370698.9263%98.5143%98.153798.9247%98.3302%98.4848%98.9696%
train_100_lenet_zip_9_iter_100000.caffemodel99.459899.449399.141%98.3429%97.784598.8972%97.9592%96.9697%98.9785%
train_100_lenet_zip_9_iter_150000.caffemodel99.392399.370699.2126%98.3429%97.717498.6766%97.5881%96.9697%99.1473%
  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值