caffe学习

学习网址是伯克利大学 http://caffe.berkeleyvision.org/tutorial/

1:Tour

Blobs, Layers, and Nets: anatomy of a Caffe model

the blob is the standard array and unified memory interface for the framework,The layer comes next as the foundation of both model and computation. The net follows as the collection and connection of layers. 

BLOB (binary large object),二进制大对象,是一个可以存储二进制文件的容器。在计算机中,BLOB常常是数据库中用来存储二进制文件的字段类型。
BLOB是一个大文件,典型的BLOB是一张图片或一个声音文件,由于它们的尺寸,必须使用特殊的方式来处理(例如:上传、下载或者存放到一个数据库)。

 

 

 

Layer类派生出来的层类通过这实现这两个虚函数,产生了各式各样功能的层类。Forward是从根据bottom计算top的过程,Backward则相反(根据top计算bottom)。注意这里为什么用了一个包含Blob的容器(vector),对于大多数Layer来说输入和输出都各连接只有一个Layer,然而对于某些Layer存在一对多的情况,比如LossLayer和某些连接层。在网路结构定义文件(*.proto)中每一层的参数bottom和top数目就决定了vector中元素数目。

 

1
2
3
4
5
6
7
8
layers {
bottom: "decode1neuron" // 该层底下连接的第一个Layer
bottom: "flatdata" // 该层底下连接的第二个Layer
top: "l2_error" // 该层顶上连接的一个Layer
name: "loss" // 该层的名字
type: EUCLIDEAN_LOSS // 该层的类型
loss_weight: 0
}

 

 

MNIST 训练

1、准备数据

cd $CAFFE_ROOT

./data/mnist/get_mnist.sh

./examples/mnist/create_mnist.sh

到caffe的根目录,下载mnist的数据,然后通过convert程序转成lmdb的格式。

2、定义网络结构

$CAFFE_ROOT/examples/mnist/lenet_train_test.prototxt

$CAFFE_ROOT/src/caffe/proto/caffe.proto     -- the protobuf definitions used by Caffe

 

posted @ 2015-12-15 15:50  闲云清烟  阅读(143)  评论(0编辑  收藏  举报