提交 0f6e8138 编写于 作者: T Tao Luo 提交者: GitHub

Merge pull request #521 from qingqing01/config_parse_bug_fix

Fix the config_parse.py if user does not set padding for Pool in the old config.
...@@ -92,7 +92,7 @@ message PoolConfig { ...@@ -92,7 +92,7 @@ message PoolConfig {
optional uint32 start = 4; optional uint32 start = 4;
// Defines the stride size between successive pooling squares. // Defines the stride size between successive pooling squares.
required uint32 stride = 5; required uint32 stride = 5 [default = 1];
// The size of output feature map. // The size of output feature map.
required uint32 output_x = 6; required uint32 output_x = 6;
...@@ -105,19 +105,19 @@ message PoolConfig { ...@@ -105,19 +105,19 @@ message PoolConfig {
optional uint32 padding = 8 [default = 0]; optional uint32 padding = 8 [default = 0];
// if not set, use size_x // if not set, use size_x
optional uint32 size_y = 9 [default = 0]; optional uint32 size_y = 9;
// if not set, use stride // if not set, use stride
optional uint32 stride_y = 10 [default = 0]; optional uint32 stride_y = 10;
// if not set, use output_x // if not set, use output_x
optional uint32 output_y = 11 [default = 0]; optional uint32 output_y = 11;
// if not set, use img_size // if not set, use img_size
optional uint32 img_size_y = 12 [default = 0]; optional uint32 img_size_y = 12;
// if not set, use padding // if not set, use padding
optional uint32 padding_y = 13 [default = 0]; optional uint32 padding_y = 13;
} }
message SppConfig { message SppConfig {
......
...@@ -592,6 +592,7 @@ class DotMulProjection(Projection): ...@@ -592,6 +592,7 @@ class DotMulProjection(Projection):
def calc_parameter_dims(self, input_size, output_size): def calc_parameter_dims(self, input_size, output_size):
return [1, output_size] return [1, output_size]
# ScalingProjection # ScalingProjection
@config_class @config_class
class ScalingProjection(Projection): class ScalingProjection(Projection):
...@@ -808,17 +809,18 @@ class BilinearInterp(Cfg): ...@@ -808,17 +809,18 @@ class BilinearInterp(Cfg):
# please refer to the comments in proto/ModelConfig.proto # please refer to the comments in proto/ModelConfig.proto
@config_class @config_class
class Pool(Cfg): class Pool(Cfg):
def __init__(self, def __init__(
pool_type, self,
channels, pool_type,
size_x, channels,
size_y=None, size_x,
img_width=None, size_y=None,
start=None, img_width=None,
stride=None, start=None,
stride_y=None, stride=None, # 1 by defalut in protobuf
padding=None, stride_y=None,
padding_y=None): padding=None, # 0 by defalut in protobuf
padding_y=None):
self.add_keys(locals()) self.add_keys(locals())
...@@ -1113,13 +1115,13 @@ def parse_pool(pool, input_layer_name, pool_conf): ...@@ -1113,13 +1115,13 @@ def parse_pool(pool, input_layer_name, pool_conf):
if pool.padding is not None: if pool.padding is not None:
pool_conf.padding = pool.padding pool_conf.padding = pool.padding
pool_conf.padding_y = default(pool.padding_y, pool_conf.padding) pool_conf.padding_y = default(pool.padding_y, pool_conf.padding)
pool_conf.output_x = cnn_output_size( pool_conf.output_x = cnn_output_size(pool_conf.img_size, pool_conf.size_x,
pool_conf.img_size, pool_conf.size_x, pool_conf.padding, pool_conf.padding, pool_conf.stride,
pool_conf.stride, False) False)
pool_conf.output_y = cnn_output_size( pool_conf.output_y = cnn_output_size(pool_conf.img_size_y, pool_conf.size_y,
pool_conf.img_size_y, pool_conf.size_y, pool_conf.padding_y, pool_conf.padding_y,
pool_conf.stride_y, False) pool_conf.stride_y, False)
def parse_spp(spp, input_layer_name, spp_conf): def parse_spp(spp, input_layer_name, spp_conf):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册