Skip to content

Commit 7b74a6d

Browse files
authored
Merge pull request #900 from wangyang59/batchNorm
fixed a bug for demo/gan caused by batchNormLayer
2 parents de353eb + a50caba commit 7b74a6d

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

demo/gan/gan_conf_image.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,9 @@ def conv_bn(input,
8787
print(imgSize, output_x, stride, filter_size, padding)
8888

8989
if trans:
90-
nameApx = "_conv"
91-
else:
9290
nameApx = "_convt"
91+
else:
92+
nameApx = "_conv"
9393

9494
if bn:
9595
conv = img_conv_layer(

python/paddle/trainer/config_parser.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1871,8 +1871,14 @@ def __init__(self,
18711871
input_layer = self.get_input_layer(0)
18721872
image_conf = self.config.inputs[0].image_conf
18731873
parse_image(self.inputs[0].image, input_layer.name, image_conf)
1874-
self.set_cnn_layer(name, image_conf.img_size_y, image_conf.img_size,
1875-
image_conf.channels, False)
1874+
1875+
# Only pass the width and height of input to batch_norm layer
1876+
# when either of it is non-zero.
1877+
if input_layer.width != 0 or input_layer.height != 0:
1878+
self.set_cnn_layer(name, image_conf.img_size_y, image_conf.img_size,
1879+
image_conf.channels, True)
1880+
else:
1881+
self.set_layer_size(input_layer.size)
18761882

18771883
psize = self.calc_parameter_size(image_conf)
18781884
dims = [1, psize]

python/paddle/trainer_config_helpers/tests/configs/protostr/img_trans_layers.protostr

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ layers {
5858
}
5959
bias_parameter_name: "___batch_norm_0__.wbias"
6060
moving_average_fraction: 0.9
61-
height: 256
62-
width: 256
6361
}
6462
layers {
6563
name: "__crmnorm_0__"

0 commit comments

Comments
 (0)