Skip to content

Commit f9469d3

Browse files
committed
add check for input height and width and input channel
1 parent c1b2353 commit f9469d3

File tree

1 file changed

+6
-1
lines changed
  • python/paddle/trainer_config_helpers

1 file changed

+6
-1
lines changed

python/paddle/trainer_config_helpers/layers.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6438,6 +6438,8 @@ def prelu_layer(input,
64386438
- channel_shared = True, we set the partial_sum to the number of outputs.
64396439
- channel_shared = False, we set the partial_sum to the number of elements in one channel.
64406440
:type channel_shared: bool
6441+
:param num_channels: number of input channel.
6442+
:type num_channels: int
64416443
:param param_attr: The parameter attribute. See ParameterAttribute for details.
64426444
:type param_attr: ParameterAttribute
64436445
:param layer_attr: The extra layer attribute. See ExtraLayerAttribute for
@@ -6455,11 +6457,14 @@ def prelu_layer(input,
64556457
assert isinstance(param_attr, ParameterAttribute)
64566458

64576459
if num_channels is None:
6458-
assert input.num_filters is not None
6460+
assert input.num_filters is not None, \
6461+
'the input channel cannot be detected, please specify the num_channels parameter'
64596462
num_channels = input.num_filters
64606463

64616464
if channel_shared is not None:
64626465
assert isinstance(channel_shared, bool)
6466+
assert (input.height != 0 and input.width != 0), \
6467+
'input height and widht must be setted'
64636468
if channel_shared:
64646469
partial_sum = input.height * input.width * num_channels
64656470
else:

0 commit comments

Comments
 (0)