Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Check whether param name is manually set when input is a sequence in fc layer #4389

Merged
merged 7 commits into from
Nov 3, 2017
14 changes: 14 additions & 0 deletions python/paddle/trainer_config_helpers/layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -1047,6 +1047,13 @@ def fc_layer(input,
if isinstance(param_attr, collections.Sequence):
assert len(input) == len(param_attr)
else:
if "parameter_name" in param_attr.attr and len(input) > 1:
logger.fatal(
"When the name field of param_attr is manually specified "
"and the input is a list, the param_attr should also be a "
"list with each item being the param_attr for each input "
"item. If only one named param_attr is provided, all the "
"input items would share this parameter.")
param_attr = [copy.deepcopy(param_attr) for _ in range(len(input))]

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

assert isinstance(input, collections.Sequence)
Expand Down