训练MNIST数据集模型

1. 数据集准备


   详细信息见: Caffe: LMDB 及其数据转换


mnist是一个手写数字库,由DL大牛Yan LeCun进行维护。mnist最初用于支票上的手写数字识别, 现在成了DL的入门练习库。征对mnist识别的专门模型是Lenet,算是最早的cnn模型了。

mnist数据训练样本为60000张,测试样本为10000张,每个样本为28*28大小的黑白图片,手写数字为0-9,因此分为10类。


1)数据可以从MNIST官网上下载)

2)或者执行如下命令

$CAFFE_ROOT表示源代码的根目录

cd $CAFFE_ROOT
./data/mnist/get_mnist.sh

运行成功后,在 data/mnist/目录下有四个文件:
train-images-idx3-ubyte:  训练集样本 (9912422 bytes) 
train-labels-idx1-ubyte:  训练集对应标注 (28881 bytes) 
t10k-images-idx3-ubyte:   测试集图片 (1648877 bytes) 
t10k-labels-idx1-ubyte:   测试集对应标注 (4542 bytes)

这些数据不能在caffe中直接使用,需要转换成LMDB数据
./examples/mnist/create_mnist.sh
下载成功会有如下两个数据集:/data/mnist-train-leveldb /data/mnist-test-leveldb.

 

2.LeNet: MNIST 分类模型的训练和测试

2.1 LeNet分类模型

使用LeNet模型网络来训练,是数字识别的好模型。The design of LeNet contains the essence of CNNs that are still used in larger models such as the ones in ImageNet. In general, it consists of a convolutional layer followed by a pooling layer, another convolution layer followed by a pooling layer, and then two fully connected layers similar to the conventional multilayer perceptrons. We have defined the layers in `$CAFFE_ROOT/examples/mnist/lenet_train_test.prototxt`.

2.2 MNIST网络结构定义

此处解释MNIST手写数字识别LeNet模型的定义 `lenet_train_test.prototxt`,Caffe中使用的protobuf 定义在 `$CAFFE_ROOT/src/caffe/proto/caffe.proto`中.接下来将会写一个protobuf定义:`caffe::NetParameter` (或者Python形式, `caffe.proto.caffe_pb2.NetParameter`) .

 开始,先定义一个网络名字:
    name: "LeNet"

2.2.1 数据层

  • 0
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值