1. 程式人生 > >caffe Python API 之卷積層(Convolution)

caffe Python API 之卷積層(Convolution)

pen project tsp otto weight value stride new constant

 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)