Skip to content

Commit a88d98c

Browse files
committed
Add comments
1 parent 6ace929 commit a88d98c

File tree

2 files changed

+9
-8
lines changed

2 files changed

+9
-8
lines changed

python/paddle/trainer/config_parser.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2400,15 +2400,14 @@ def __init__(self, name, inputs, axis, offset, shape, **xargs):
24002400
image_conf.img_size_y = input_layer.height
24012401
image_conf.channels = input_layer.size / (input_layer.width *
24022402
input_layer.height)
2403-
2403+
# only support for 4-dims inputs and NCHW order
24042404
if (len(self.config.inputs) == 2):
24052405
self.set_layer_height_width(
24062406
self.get_input_layer(1).height, self.get_input_layer(1).width)
24072407
self.set_layer_size(self.get_input_layer(1).size)
24082408
else:
2409-
# NCHW order
24102409
self.set_layer_height_width(shape[-2], shape[-1])
2411-
self.set_layer_size(reduce(lambda x, y: x * y, shape))
2410+
self.set_layer_size(reduce(lambda x, y: x * y, shape[1:]))
24122411

24132412

24142413
@config_layer('batch_norm')
@@ -3865,18 +3864,19 @@ def __init__(self, name, inputs, reshape, **xargs):
38653864
else:
38663865
in_h = input_layer.height
38673866
in_w = input_layer.width
3867+
out_dims = None
38683868
if input_layer.has_depth():
38693869
in_d = input_layer.depth
38703870
in_c = input_layer.size / in_h / in_w / in_d
3871+
# batch_size, depth, height, width, channel
38713872
out_dims = [0, in_d, in_h, in_w, in_c]
3872-
size = reduce(lambda x, y: x * y,
3873-
out_dims[reshape['width'][0]:])
38743873
else:
38753874
in_c = input_layer.size / in_h / in_w
3875+
# batch_size, height, width, channel
38763876
out_dims = [0, in_h, in_w, in_c]
3877-
size = reduce(lambda x, y: x * y,
3878-
out_dims[reshape['width'][0]:])
3879-
3877+
# Because (reshape['width'][0] > 0) always be true.
3878+
# So out_dims[0] won't be used.
3879+
size = reduce(lambda x, y: x * y, out_dims[reshape['width'][0]:])
38803880
self.set_layer_size(size)
38813881

38823882

python/paddle/trainer_config_helpers/layers.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6854,6 +6854,7 @@ def crop_layer(input, offset, axis=2, shape=None, name=None, layer_attr=None):
68546854
68556855
:param input: The input of this layer. If two inputs are given, the second one
68566856
will be regarded as the reference.
6857+
And the input must be 4-dims and in NCHW order.
68576858
:type input: LayerOutput | Sequence
68586859
:param offset: The crop offset.
68596860
:type offset: Sequence

0 commit comments

Comments
 (0)