您的位置:首页 > 理论基础 > 计算机网络

caffe 实践程序4——cifar10网络

2016-07-29 15:57 597 查看
cifar10是个中小型的图片数据库,总共60000张32*32大小的图片,5w张用于训练,1w张用于测试。

caffe上cifar10的训练流程

cifar10_quick_train_test.prototxt

[html] view
plain copy

 





name: "CIFAR10_quick"  

layer {  

  name: "cifar"  

  type: "Data"  

  top: "data"  

  top: "label"  

  include {  

    phase: TRAIN  

  }  

  transform_param {  

    mean_file: "examples/cifar10/mean.binaryproto"  

  }  

  data_param {  

    source: "examples/cifar10/cifar10_train_lmdb"  

    batch_size: 100  

    backend: LMDB  

  }  

}  

layer {  

  name: "cifar"  

  type: "Data"  

  top: "data"  

  top: "label"  

  include {  

    phase: TEST  

  }  

  transform_param {  

    mean_file: "examples/cifar10/mean.binaryproto"  

  }  

  data_param {  

    source: "examples/cifar10/cifar10_test_lmdb"  

    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  

    pad: 2  

    kernel_size: 5  

    stride: 1  

    weight_filler {  

      type: "gaussian"  

      std: 0.0001  

    }  

    bias_filler {  

      type: "constant"  

    }  

  }  

}  

layer {  

  name: "pool1"  

  type: "Pooling"  

  bottom: "conv1"  

  top: "pool1"  

  pooling_param {  

    pool: MAX  

    kernel_size: 3  

    stride: 2  

  }  

}  

layer {  

  name: "relu1"  

  type: "ReLU"  

  bottom: "pool1"  

  top: "pool1"  

}  

layer {  

  name: "conv2"  

  type: "Convolution"  

  bottom: "pool1"  

  top: "conv2"  

  param {  

    lr_mult: 1  

  }  

  param {  

    lr_mult: 2  

  }  

  convolution_param {  

    num_output: 32  

    pad: 2  

    kernel_size: 5  

    stride: 1  

    weight_filler {  

      type: "gaussian"  

      std: 0.01  

    }  

    bias_filler {  

      type: "constant"  

    }  

  }  

}  

layer {  

  name: "relu2"  

  type: "ReLU"  

  bottom: "conv2"  

  top: "conv2"  

}  

layer {  

  name: "pool2"  

  type: "Pooling"  

  bottom: "conv2"  

  top: "pool2"  

  pooling_param {  

    pool: AVE  

    kernel_size: 3  

    stride: 2  

  }  

}  

layer {  

  name: "conv3"  

  type: "Convolution"  

  bottom: "pool2"  

  top: "conv3"  

  param {  

    lr_mult: 1  

  }  

  param {  

    lr_mult: 2  

  }  

  convolution_param {  

    num_output: 64  

    pad: 2  

    kernel_size: 5  

    stride: 1  

    weight_filler {  

      type: "gaussian"  

      std: 0.01  

    }  

    bias_filler {  

      type: "constant"  

    }  

  }  

}  

layer {  

  name: "relu3"  

  type: "ReLU"  

  bottom: "conv3"  

  top: "conv3"  

}  

layer {  

  name: "pool3"  

  type: "Pooling"  

  bottom: "conv3"  

  top: "pool3"  

  pooling_param {  

    pool: AVE  

    kernel_size: 3  

    stride: 2  

  }  

}  

layer {  

  name: "ip1"  

  type: "InnerProduct"  

  bottom: "pool3"  

  top: "ip1"  

  param {  

    lr_mult: 1  

  }  

  param {  

    lr_mult: 2  

  }  

  inner_product_param {  

    num_output: 64  

    weight_filler {  

      type: "gaussian"  

      std: 0.1  

    }  

    bias_filler {  

      type: "constant"  

    }  

  }  

}  

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: "gaussian"  

      std: 0.1  

    }  

    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"  

}  

之前做可视化,导师想通过改变网络层数训练模型,进而观察可视化结果,来评估网络好坏程度及为修改网络参数提供方案。

一张32*32大小的图片输入网络,变动如下:

[html] view
plain copy

 





conv1     100     32     32*32  

pool1     100     32     16*16  

conv2     100     32     16*16  

pool2     100     32     8*8  

conv3     100     64     8*8  

pool3     100     64     4*4  

ip1       100     64     1*1  

ip1       100     10     1*1  

因为conv1中的pad参数,所以从conv1出来的大小为(32+2×pad-kernel_size+stride)/stride=32,即输入是32*32,输出也是32*32。

现在在原网络增加两大层(一个大层是指:conv,pool,relu),中间有5大层时,网络已达极限,因为原始图片为32*32大小,

网络5:data ->cpr1->crp2->crp3->crp4->crp5->ip1->ip2    识别率:53%  52.29%

若再增加层数识别率均为10%,现原因不明

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: