DeepLearning(基于caffe)实战项目(6)--探索leNet模型的真谛

        到目前为止,我们训好了模型,测试了模型,也知道如何看学习曲线,那么就很好奇,通过怎么个流程,能让一幅图片转换成了一个结果(数字),接下来将一探究竟

        首先,需要明确的是我们训练集是60000张32*32的图片,测试集是10000张32*32的图片。

第一层 卷积层(C1)

输入:1*32*32

卷积核大小:5*5

feature map个数:20

输出的feature map大小:28*28(32-5+1)

输出:20*28*28

相应的配置文件代码:

layer {
  name: "conv1"    //卷积神经网络的第一层,卷积层
  type: "Convolution"    //这层操作为卷积
  bottom: "data"   //层的输入为data
  top: "conv1"     //层的输出为conv1
  param {
    lr_mult: 1     //权值学习速率倍乘因子,1倍表示保持与全局参数一致
  }
  param {
    lr_mult: 2     //bias学习倍率倍乘因子,是全局参数的2倍
  }
  convolution_param {
    num_output: 20    //输出特征图个数
    kernel_size: 5    //卷积核大小
    stride: 1         //卷积输出跳跃间隔,1表示连续输出
    weight_filler {   //权值使用xavier填充器
      type: "xavier"
    }
    bias_filler {     //bias使用常数填充器,默认为0
      type: "constant"
    }
  }
}

第二层 下采样层(S2)

输入:20*28*28

采样区域:2*2

feature map个数:20

输出的feature map大小:14*14(28/2)

输出:20*14*14

相应的配置文件代码:

layer {
  name: "pool1"
  type: "Pooling"    //池化层,这一层的操作为池化
  bottom: "conv1"    //层的输入为conv1
  top: "pool1"       //层的输出为pool1
  pooling_param {
    pool: MAX        //最大池化
    kernel_size: 2   //下采样窗口尺寸2*2
    stride: 2        //下采样输出跳跃间隔2*2
  }
}

第三层 卷积层(C3)

输入:20*14*14

卷积核大小:5*5

feature map个数:50

输出的feature map大小:10*10(14-5+1)

输出:50*10*10

相应的配置文件代码:

layer {              //新的卷积层,和conv1类似
  name: "conv2"
  type: "Convolution"
  bottom: "pool1"
  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"
    }
  }
}

第四层 下采样层(S4)

输入:50*10*10

采样区域:2*2

feature map个数:50

输出的feature map大小:5*5(10/2)

输出:50*5*5

相应的配置文件代码:

layer {              //新的下采样层,和pool1类似
  name: "pool2"
  type: "Pooling"
  bottom: "conv2"
  top: "pool2"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}

第五层 全连接层(F5)

输入:50*5*5

feature map个数:500

输出的feature map大小:1*1

输出:500*1*1

相应的配置文件代码:

layer {              //新的全连接层
  name: "ip1"
  type: "InnerProduct"
  bottom: "pool2"    //输入为pool2
  top: "ip1"         //输出为ip1
  param {
    lr_mult: 1
  }
  param {
    lr_mult: 2
  }
  inner_product_param {
    num_output: 500
    weight_filler {
      type: "xavier"
    }
    bias_filler {
      type: "constant"
    }
  }
}

第六层 RELU层(R6)

输入:500*1*1

feature map个数:500

输出的feature map大小:1*1

输出:500*1*1

相应的配置文件代码:

layer {              //新的非线性层,用ReLU方法
  name: "relu1"
  type: "ReLU"
  bottom: "ip1"      
  top: "ip1"
}

第七层 全连接层(F7)

输入:500*1*1

feature map个数:10

输出的feature map大小:1*1

输出:10*1*1

注意:这层输出是一个10行1列的数字,表示0-9的概率

相应的配置文件代码:

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"
    }
  }
}
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值