2017-08-27 45 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上报告过,但由于向后兼容性问题尚未解决。

相关问题