Skip to content

Commit 83c2281

Browse files
authored
Merge pull request #4389 from will-am/fix-4388
Check whether param name is manually set when input is a sequence in fc layer
2 parents aa5664c + 5c80d1b commit 83c2281

File tree

1 file changed

+14
-0
lines changed
  • python/paddle/trainer_config_helpers

1 file changed

+14
-0
lines changed

python/paddle/trainer_config_helpers/layers.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1047,6 +1047,13 @@ def fc_layer(input,
10471047
if isinstance(param_attr, collections.Sequence):
10481048
assert len(input) == len(param_attr)
10491049
else:
1050+
if "parameter_name" in param_attr.attr and len(input) > 1:
1051+
logger.fatal(
1052+
"When the name field of param_attr is manually specified "
1053+
"and the input is a list, the param_attr should also be a "
1054+
"list with each item being the param_attr for each input "
1055+
"item. If only one named param_attr is provided, all the "
1056+
"input items would share this parameter.")
10501057
param_attr = [copy.deepcopy(param_attr) for _ in range(len(input))]
10511058

10521059
assert isinstance(input, collections.Sequence)
@@ -4877,6 +4884,13 @@ def selective_fc_layer(input,
48774884
if isinstance(param_attr, collections.Sequence):
48784885
assert len(input) == len(param_attr)
48794886
else:
4887+
if "parameter_name" in param_attr.attr and len(input) > 1:
4888+
logger.fatal(
4889+
"When the name field of param_attr is manually specified "
4890+
"and the input is a list, the param_attr should also be a "
4891+
"list with each item being the param_attr for each input "
4892+
"item. If only one named param_attr is provided, all the "
4893+
"input items would share this parameter.")
48804894
param_attr = [copy.deepcopy(param_attr) for _ in range(len(input))]
48814895

48824896
assert isinstance(input, collections.Sequence)

0 commit comments

Comments
 (0)