Caffe (Convolution Architecture For Feature Embedding
(Extraction))
网络各层详细解释
http://caffe.berkeleyvision.org/tutorial/layers.html
Questions:
1. 从中断处开始训练
caffe train solver solver.prototxt snapshot train_1000.solverstate
https://github.com/BVLC/caffe/wiki/Training-and-Resuming
2. 可视化卷积层
name: "myconvnet"
input: "data"
input_dim: 1
input_dim: 1
input_dim: 256
input_dim: 256
layer {
name: "conv"
type: "Convolution"
bottom: "data"
top: "conv"
convolution_param {
num_output: 10
kernel_size: 3
stride: 1
weight_filler {
type: "gaussian"
std: 0.01
} b
ias_filler {
type: "constant"
value: 0
}
}
}
$ pip insall pydot
$ sudo aptget install graphviz libgraphvizdev
$ pip install pygraphviz
$ python /path/to/caffe/python/draw_net.py myconvnet.prototxt
myconvnet.png
3. 什么样的 layer 才能它的 bottom 和 top 可以是相同的名称?
目前只有 Relu 层它的上下层可以使用相同名称,因为它是 element-wise 的,
所以可以使用 in-place 的操作以节省内存
http://caffe.berkeleyvision.org/tutorial/interfaces.html
4. 测试网络
impoort sys
sys.path.insert(0, '/path/to/caffe/python')
import numpy as np
import cv2
from pylab import * #画图
import caffe
#initialize
caffe.set_device(1) caffe.set_mode_gpu() | #指定使用哪一块GPU #指定GPU计算 |
model_def = 'deploy.prototxt' model_weight = 'net.cafffemodel' | #给定网络模型 #给定参数 |
net = caffe.Net(model_def, model_weight, caffe.TEST) | #给定phase = |
TEST, | 那么网络只会向前计算,不会 backpropagation |
Net instance:
1. Mnist
http://caffe.berkeleyvision.org/gathered/examples/mnist.html