ubuntu14.04用cafe训练自己的数据

训练mnist数据集并测试
1.获取数据集
cd ~/caffe
./data/mnist/get_mnist.sh

2.转换格式,下载的数据是二进制格式,转换成lmdb格式
./examples/mnist/create_mnist.sh

3.训练数据集
./examples/mnist/train_lenet.sh

4.测试数据集
./build/tools/caffe.bin test -model examples/mnist/lenet_train_test.prototxt -weights examples/mnist/lenet_iter_10000.caffemodel -iterations 100


训练并测试自己的数据集
1.数据集放在./home/iscas/caffe/data/image1000test200  数据集是在windows7制作的2.
2.转换数据集格式并生成均值
参见/home/iscas/caffe/examples/image1000test200/create_image1000test200.sh,具体内容如下所示:

#!/usr/bin/env sh
# This script converts the cifar data into leveldb format.
set -e

EXAMPLE=examples/image1000test200
DATA=data/image1000test200
DBTYPE=lmdb

TRAIN_DATA_ROOT=/home/iscas/caffe/data/image1000test200/train/
VAL_DATA_ROOT=/home/iscas/caffe/data/image1000test200/val/


RESIZE_HEIGHT=32
RESIZE_WIDTH=32


echo "Creating $DBTYPE..."

rm -rf $EXAMPLE/image1000test200_train_$DBTYPE $EXAMPLE/image1000test200_val_$DBTYPE

./build/tools/convert_imageset.bin --resize_height=$RESIZE_HEIGHT --resize_width=$RESIZE_WIDTH $TRAIN_DATA_ROOT $DATA/train.txt $EXAMPLE/image1000test200_train_lmdb $DBTYPE

./build/tools/convert_imageset.bin --resize_height=$RESIZE_HEIGHT --resize_width=$RESIZE_WIDTH $VAL_DATA_ROOT $DATA/val.txt $EXAMPLE/image1000test200_val_lmdb $DBTYPE

echo "Computing image mean..."

./build/tools/compute_image_mean -backend=$DBTYPE \
  $EXAMPLE/image1000test200_train_$DBTYPE $EXAMPLE/mean.binaryproto

echo "Done."


3.生成mine_solver.prototxt和mine_train_test.prototxt两个文件,放在/home/iscas/caffe/data/image1000test200/train_val/ 文件夹下
4.训练网络
参见/home/iscas/caffe/examples/image1000test200/image1000test200_train.sh,具体内容如下所示:

#!/usr/bin/env sh
set -e

TOOLS=./build/tools

$TOOLS/caffe train \

  --solver=data/image1000test200/train_val/mine_solver.prototxt $@


你可能感兴趣的:(深度学习)