700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > caffe学习日记--lesson4:windows下caffe DEMO (mnist and cifar10)

caffe学习日记--lesson4:windows下caffe DEMO (mnist and cifar10)

时间:2021-06-24 12:27:48

相关推荐

caffe学习日记--lesson4:windows下caffe DEMO (mnist and cifar10)

caffe学习日记--lesson4:windows下caffe DEMO (mnist and cifar10)

1.下载数据 mnist官网:/exdb/mnist/

2.数据格式转化 使用编译得到的convent_mnist_data.exe程序,得到lmdb格式的数据(lmdb的内存消耗是leveldb的1.1倍,但是lmdb的速度比leveldb快10%至15%,重要的是lmdb允许多种训练模型同时读取同一组数据集。 )

..\..\Build\x64\Release\convert_mnist_data.exe train-images.idx3-ubyte train-labels.idx1-ubyte .\lmdb\train_lmdb..\..\Build\x64\Release\convert_mnist_data.exe t10k-images.idx3-ubyte t10k-labels.idx1-ubyte .\lmdb\test_lmdbpause

简单说明:exe 数据 标签 保存的到文件 (其中lmdb目录实现建立好) ..\ 相对路径回到上一级目录 .\ 当前目录下,

3.配置文件的编写 3.1 lenet_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: "../../data/mnist/lmdb/train_lmdb"batch_size: 64backend: LMDB}}layer {name: "mnist"type: "Data"top: "data"top: "label"include {phase: TEST}transform_param {scale: 0.00390625}data_param {source: "../../data/mnist/lmdb/test_lmdb"batch_size: 100backend: LMDB}}layer {name: "conv1"type: "Convolution"bottom: "data"top: "conv1"param {lr_mult: 1}param {lr_mult: 2}convolution_param {num_output: 20kernel_size: 5stride: 1weight_filler {type: "xavier"}bias_filler {type: "constant"}}}layer {name: "pool1"type: "Pooling"bottom: "conv1"top: "pool1"pooling_param {pool: MAXkernel_size: 2stride: 2}}layer {name: "conv2"type: "Convolution"bottom: "pool1"top: "conv2"param {lr_mult: 1}param {lr_mult: 2}convolution_param {num_output: 50kernel_size: 5stride: 1weight_filler {type: "xavier"}bias_filler {type: "constant"}}}layer {name: "pool2"type: "Pooling"bottom: "conv2"top: "pool2"pooling_param {pool: MAXkernel_size: 2stride: 2}}layer {name: "ip1"type: "InnerProduct"bottom: "pool2"top: "ip1"param {lr_mult: 1}param {lr_mult: 2}inner_product_param {num_output: 500weight_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: 10weight_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"}

3.2 lenet_solver.prototxt

net: "lenet_train_test.prototxt" test_iter: 100test_interval: 500base_lr: 0.01momentum: 0.9weight_decay: 0.0005lr_policy: "inv"gamma: 0.0001power: 0.75display: 100max_iter: 10000snapshot: 5000snapshot_prefix: "./models/lenet"solver_mode: GPU

3.3 bat

..\..\Build\x64\Release\caffe train --solver=lenet_solver.prototxtpause

具体语法参考:/denny402/tag/caffe/ 作为学术研究人员,应当熟练书写各种prototxt文件。 4.训练 注意bat文件和solver.prototxt,lenet_train_test.prototxt 文件放在同一级目录,且新建文件夹models用来保存caffemodel 运行bat,即可训练模型,得到caffemodel

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。