windows下caffe运行我的第二个程序

来源:互联网 发布:淘宝的网商银行 编辑:程序博客网 时间:2024/05/29 13:56

我的第二个程序时运行caffe自带的mnist手写数据。具体过程如下:

一、获取数据

可以从我的网盘中下载:

链接:http://pan.baidu.com/s/1dEVYUHj 密码:joyq

包含4个文件。

2个是训练集的:train-images.idx3-ubyte(训练集照片)和train-labels.idx1-ubyte(训练集照片对应的label).

2个是测试集的:t10k-images.idx3-ubyte(测试集照片)和t10k-labels.idx1-ubyte(测试集照片对应的label).

在数据放置在examples/mnist/文件夹下新建mnist_data文件夹,并将以上4个文件复制过去。

二、将数据转为leveldbd文件

此处我们换用一下方法,但是换汤不换药。

在caffe-master根目录下新建bat文件。convert_mnist_train.bat文件。并写入一下代码:

Build\x64\Debug\convert_mnist_data.exe --backend=lmdb examples\mnist\mnist_data\train-images.idx3-ubyte examples\mnist\mnist_data\train-labels.idx1-ubyte examples\mnist\mnist_data\mnist_train_lmdb  pause

再新建文件convert_mnist_test.bat.写入如下代码:


此处采用的均是相对路径。此处,将文件转换为lmdb文件。

PS:convert_mnist_data.exe的使用格式:

convert_mnist_data.exe [FLAGS] Input_Image_File Input_Label_File OutPut_db_File

[FLAGS]:图片参数组

-gray:是否以灰度图的方式打开图片,默认为false。程序调用opencv库中的imread()函数来打开图片。

-shuffle:是否随机打乱图片顺序,默认为false。

-backend:需要转换成的文件格式,可设置为leveldb或者lmdb.

-reseize_width/resize_height:改变图片的大小。要求程序在运行中,要保证所有图片的大小一致。程序调用opencv库中的resize()函数对图片进行放缩。默认为false,即不变化。

Input_Image_File :输入图片的位置

Input_Label_File :图片文件列表清单,也就是输入图片的类标label。

OutPut_db_File:最终生成的db文件的存放位置。

三、运行程序

首先在examples/mnist/文件夹下面找到lenet_solver.prototxt文件。修改solver_mode=CPU.

将刚刚生成的两个文件夹剪切到examples/mnist/下。或者不动,修改lenet_train_test.prototxt的source。

在caffe-master根目录下新建.bat文件。写入代码如下:

.\Build\x64\Debug\caffe.exe train --solver=examples/mnist/lenet_solver.prototxtpause
即可运行。




1 0
原创粉丝点击