Skip to content

Commit d069f2c

Browse files
authored
Make fluid.layers.fc support multiple param_attr (#6532)
Fix #6531
1 parent 1ba8f7f commit d069f2c

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

python/paddle/v2/fluid/param_attr.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ def set_default_bias_initializer(self):
3636
def to_attr(arg):
3737
if arg is None:
3838
return ParamAttr()
39+
elif isinstance(arg, list) or isinstance(arg, tuple):
40+
return [ParamAttr.to_attr(a) for a in arg]
3941
elif isinstance(arg, ParamAttr):
4042
return arg
4143
elif isinstance(arg, str) or isinstance(arg, unicode):

python/paddle/v2/fluid/tests/test_layers.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,10 @@ def test_recognize_digits_mlp(self):
2929
label = layers.data(name='label', shape=[1], dtype='int32')
3030
hidden1 = layers.fc(input=images, size=128, act='relu')
3131
hidden2 = layers.fc(input=hidden1, size=64, act='relu')
32-
predict = layers.fc(input=hidden2, size=10, act='softmax')
32+
predict = layers.fc(input=[hidden2, hidden1],
33+
size=10,
34+
act='softmax',
35+
param_attr=["sftmax.w1", "sftmax.w2"])
3336
cost = layers.cross_entropy(input=predict, label=label)
3437
avg_cost = layers.mean(x=cost)
3538
self.assertIsNotNone(avg_cost)

0 commit comments

Comments
 (0)