caffe Python API 之卷积层(Convolution)

Posted HOU_JUN

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了caffe Python API 之卷积层(Convolution)相关的知识,希望对你有一定的参考价值。

 1 import sys
 2 sys.path.append(/projects/caffe-ssd/python)
 3 import caffe
 4 
 5 net = caffe.NetSpec()
 6 # net.data ,net.label = caffe.layers.ImageData(
 7 #     source="train.txt",
 8 #     batch_size=32,
 9 #     new_width=48,
10 #     new_height=48,
11 #     ntop=2,
12 #     is_color=True,
13 #     shuffle=True,
14 #     root_folder=‘/‘,
15 #     transform_param=dict(crop_size=40,mirror=True))
16 
17 net.data, net.label = caffe.layers.Data(
18     name="InputData",
19     source="train_lmdb",
20     backend = caffe.params.Data.LMDB,
21     batch_size=32,
22     ntop=2,
23     transform_param=dict(
24         crop_size=227,
25         mean_value=[104, 117, 123],
26         mirror=True
27     )
28 )
29 
30 net.conv1 = caffe.layers.Convolution(
31     net.data,
32     name="Conv1",
33     kernel_size=3,
34     stride=1,
35     pad=1,
36     num_output=20,
37     group=2,
38     weight_filler=dict(type=xavier),
39     bias_filler=dict(type=constant,value=0))
40 
41 print str(net.to_proto())
42 
43 输出:
44 layer {
45   name: "InputData"
46   type: "Data"
47   top: "data"
48   top: "label"
49   transform_param {
50     mirror: true
51     crop_size: 227
52     mean_value: 104
53     mean_value: 117
54     mean_value: 123
55   }
56   data_param {
57     source: "train_lmdb"
58     batch_size: 32
59     backend: LMDB
60   }
61 }
62 layer {
63   name: "Conv1"
64   type: "Convolution"
65   bottom: "data"
66   top: "conv1"
67   convolution_param {
68     num_output: 20
69     pad: 1
70     kernel_size: 3
71     group: 2
72     stride: 1
73     weight_filler {
74       type: "xavier"
75     }
76     bias_filler {
77       type: "constant"
78       value: 0
79     }
80   }
81 }

 

以上是关于caffe Python API 之卷积层(Convolution)的主要内容,如果未能解决你的问题,请参考以下文章

caffe之卷积层

caffe之pooling层

caffe之loss层

查找 Caffe 卷积滤波器相对于输入的梯度

caffe源码 卷积层

Caffe 源码阅读 卷积层