Skip to content

Commit

Permalink
Make fluid.layers.fc support multiple param_attr (#6532)
Browse files Browse the repository at this point in the history
Fix #6531
  • Loading branch information
reyoung authored Dec 13, 2017
1 parent 1ba8f7f commit d069f2c
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
2 changes: 2 additions & 0 deletions python/paddle/v2/fluid/param_attr.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,8 @@ def set_default_bias_initializer(self):
def to_attr(arg):
if arg is None:
return ParamAttr()
elif isinstance(arg, list) or isinstance(arg, tuple):
return [ParamAttr.to_attr(a) for a in arg]
elif isinstance(arg, ParamAttr):
return arg
elif isinstance(arg, str) or isinstance(arg, unicode):
Expand Down
5 changes: 4 additions & 1 deletion python/paddle/v2/fluid/tests/test_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,10 @@ def test_recognize_digits_mlp(self):
label = layers.data(name='label', shape=[1], dtype='int32')
hidden1 = layers.fc(input=images, size=128, act='relu')
hidden2 = layers.fc(input=hidden1, size=64, act='relu')
predict = layers.fc(input=hidden2, size=10, act='softmax')
predict = layers.fc(input=[hidden2, hidden1],
size=10,
act='softmax',
param_attr=["sftmax.w1", "sftmax.w2"])
cost = layers.cross_entropy(input=predict, label=label)
avg_cost = layers.mean(x=cost)
self.assertIsNotNone(avg_cost)
Expand Down

0 comments on commit d069f2c

Please sign in to comment.