2017-08-27 46 views
0

根據我的計算,池化輸出應該5x4x4(5個大小爲4x4的特徵地圖),如此扁平化將產生1x80的向量。因此fc3的重量應該是20x80,但pycaffe顯示的是20x125的重量。這裏是prototext文件。這裏是我的計算完全連接的圖層稱爲fc3如何有20x125的權重


方程式用途(dimension_size - 內核)/步幅+ 1

CONV 1:1x5x26x26
池1:1x5x12x12
CONV 2:1x5x10x10
POOL2:1x5x4x4

input: "data" 
input_shape { 
    dim: 1 
    dim: 1 
    dim: 28 
    dim: 28 
} 
layer { 
    name: "conv1" 
    type: "Convolution" 
    bottom: "data" 
    top: "conv1" 
    param { 
    lr_mult: 1.0 
    decay_mult: 1.0 
    } 
    param { 
    lr_mult: 2.0 
    decay_mult: 0.0 
    } 
    convolution_param { 
    num_output: 5 
    kernel_size: 3 
    stride: 1 
    weight_filler { 
     type: "gaussian" 
     std: 0.01 
    } 
    bias_filler { 
     type: "constant" 
     value: 0.0 
    } 
    } 
} 
layer { 
    name: "relu1" 
    type: "ReLU" 
    bottom: "conv1" 
    top: "conv1" 
} 
layer { 
    name: "pool1" 
    type: "Pooling" 
    bottom: "conv1" 
    top: "pool1" 
    pooling_param { 
    pool: MAX 
    kernel_size: 3 
    stride: 2 
    } 
} 
layer { 
    name: "conv2" 
    type: "Convolution" 
    bottom: "pool1" 
    top: "conv2" 
    param { 
    lr_mult: 1.0 
    decay_mult: 1.0 
    } 
    param { 
    lr_mult: 2.0 
    decay_mult: 0.0 
    } 
    convolution_param { 
    num_output: 5 
    kernel_size: 3 
    stride: 1 
    weight_filler { 
     type: "gaussian" 
     std: 0.01 
    } 
    bias_filler { 
     type: "constant" 
     value: 0.1 
    } 
    } 
} 
layer { 
    name: "relu2" 
    type: "ReLU" 
    bottom: "conv2" 
    top: "conv2" 
} 
layer { 
    name: "pool2" 
    type: "Pooling" 
    bottom: "conv2" 
    top: "pool2" 
    pooling_param { 
    pool: MAX 
    kernel_size: 3 
    stride: 2 
    } 
} 
layer { 
    name: "fc3" 
    type: "InnerProduct" 
    bottom: "pool2" 
    top: "fc3" 
    param { 
    lr_mult: 1.0 
    decay_mult: 1.0 
    } 
    param { 
    lr_mult: 2.0 
    decay_mult: 0.0 
    } 
    inner_product_param { 
    num_output: 20 
    weight_filler { 
     type: "gaussian" 
     std: 0.005 
    } 
    bias_filler { 
     type: "constant" 
     value: 0.1 
    } 
    } 
} 
layer { 
    name: "relu3" 
    type: "ReLU" 
    bottom: "fc3" 
    top: "fc3" 
} 
layer { 
    name: "drop3" 
    type: "Dropout" 
    bottom: "fc3" 
    top: "fc3" 
    dropout_param { 
    dropout_ratio: 0.5 
    } 
} 
layer { 
    name: "fc4" 
    type: "InnerProduct" 
    bottom: "fc3" 
    top: "fc4" 
    param { 
    lr_mult: 1.0 
    decay_mult: 1.0 
    } 
    param { 
    lr_mult: 2.0 
    decay_mult: 0.0 
    } 
    inner_product_param { 
    num_output: 10 
    weight_filler { 
     type: "gaussian" 
     std: 0.01 
    } 
    bias_filler { 
     type: "constant" 
     value: 0.0 
    } 
    } 
} 
layer { 
    name: "softmax" 
    type: "Softmax" 
    bottom: "fc4" 
    top: "softmax" 
} 

回答

0

事實證明,對於最大池caffe四捨五入輸出大小,而不是截斷,如果它是一個分數。因此會產生不正確的形狀。該問題已在GitHub上報告過,但由於向後兼容性問題尚未解決。

相關問題