Skip to content

Commit b130ba7

Browse files
Haonanemailweixu
authored andcommitted
fixed bugs in conv_operator; add calc_output_size (#101)
1 parent 2c5a6ac commit b130ba7

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

python/paddle/trainer/config_parser.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,6 @@ def __init__(
636636
input_layer_names,
637637
):
638638
self.add_keys(locals())
639-
640639
self.operator_conf = OperatorConfig()
641640
self.operator_conf.type = self.type
642641

@@ -686,12 +685,15 @@ def __init__(
686685
if num_filters is not None:
687686
self.operator_conf.num_filters = num_filters
688687

689-
parse_conv(conv_conf, input_layer_names[0], self.operator_conf.conv_conf, True)
688+
parse_conv(conv_conf,
689+
MakeLayerNameInSubmodel(input_layer_names[0]),
690+
self.operator_conf.conv_conf)
690691
self.operator_conf.output_size = (self.operator_conf.conv_conf.output_x ** 2) * num_filters
691692

692693
config_assert(len(input_layer_names) == 2, "Conv is binary operator")
693694

694-
695+
def calc_output_size(self, input_sizes):
696+
return self.operator_conf.output_size
695697

696698

697699
# please refer to the comments in proto/ModelConfig.proto

python/paddle/trainer_config_helpers/layers.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2668,7 +2668,7 @@ def __add_evaluator__(e):
26682668
return LayerOutput(name, LayerType.COST, parents=[input, label])
26692669

26702670
def conv_operator(input, filter_size, num_filters,
2671-
num_channel=None, stride=1, padding=0,
2671+
num_channel=None, stride=1, padding=0, groups=1,
26722672
filter_size_y=None, stride_y=None, padding_y=None):
26732673
"""
26742674
Different from img_conv_layer, conv_op is an Operator, which can be used
@@ -2715,15 +2715,16 @@ def conv_operator(input, filter_size, num_filters,
27152715
stride_y = stride
27162716
if padding_y is None:
27172717
padding_y = padding
2718-
op = ConvOperator(input_layer_name=[x.name for x in input],
2718+
op = ConvOperator(input_layer_names=[x.name for x in input],
27192719
num_filters = num_filter,
27202720
conv_conf=Conv(filter_size=filter_size,
27212721
padding=padding,
27222722
stride=stride,
27232723
channels=num_channel,
27242724
filter_size_y=filter_size_y,
27252725
padding_y=padding_y,
2726-
stride_y=stride_y))
2726+
stride_y=stride_y,
2727+
groups=groups))
27272728
op.origin = input
27282729
op.origin.operator = "conv_op"
27292730
return op

0 commit comments

Comments
 (0)