【深度学习】LeNet 网络

Introduce

1998年的 LeNet-5 标志着 CNN的真正面世

该网络在字符识别上取得了高于99%的准确率,因此主要被用于字符识别的卷积神经网络。

但是这个模型在后来的一段时间并未能火起来,主要原因是费机器(当时尚未有GPU),而且在非OCR的任务上,其他的算法(如SVM)也能达到类似的效果甚至超过。

Structure

L e N e t = ( c o n v + m a x p o o l i n g ) × 2 + f c × 2 + G a u s s i a n LeNet = (conv+maxpooling)×2 + fc×2 + Gaussian LeNet=(conv+maxpooling)×2+fc×2+Gaussian
这里写图片描述

其中,每一个“矩形”代表一张特征图,最后是两层全连接层。

Code

标准代码引自 BVLC/caffe/examples/mnist/lenet.prototxt

name: "LeNet"

# ========== 输入 ==========
layer {
  name: "data"
  type: "Input"
  top: "data"
  input_param { shape: { dim: 64 dim: 1 dim: 28 dim: 28 } }
}

# ========== 第一层 ==========
layer {    # 卷积
  name: "conv1"
  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 {    # max池化
  name: "pool1"
  type: "Pooling"
  bottom: "conv1"
  top: "pool1"
  pooling_param {
    pool: MAX
    kernel_size: 2
    stride: 2
  }
}

# ========== 第二层 ==========
layer {    # 卷积
  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"
    }
  }
}
layer {    # max池化
  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 {    # relu激活函数
  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 {    # Softmax
  name: "prob"
  type: "Softmax"
  bottom: "ip2"
  top: "prob"
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值