-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Fix sublayer #31824
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
Fix sublayer #31824
Changes from 8 commits
3bc78c5
e28cb56
961a95c
44d9cb1
595548b
ec20507
be65ae3
c8b4b01
3c3a6be
a0ea150
dee3e6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -3718,6 +3718,35 @@ def test_set_train_eval_in_static_mode(self): | |
| self.assertFalse(net.training) | ||
|
|
||
|
|
||
| class MyLayer(paddle.nn.Layer): | ||
| def __init__(self): | ||
| super(MyLayer, self).__init__() | ||
| self._linear = paddle.nn.Linear(1, 1) | ||
| self._dropout = paddle.nn.Dropout(p=0.5) | ||
|
|
||
| def forward(self, input): | ||
| temp = self._linear(input) | ||
| temp = self._dropout(temp) | ||
| return temp | ||
|
|
||
|
|
||
| class MySuperLayer(paddle.nn.Layer): | ||
| def __init__(self): | ||
| super(MySuperLayer, self).__init__() | ||
| self._mylayer = MyLayer() | ||
|
|
||
| def forward(self, input): | ||
| temp = self.mylayer(input) | ||
| return temp | ||
|
|
||
|
|
||
| class TestSubLayerCount(unittest.TestCase): | ||
| def test_sublayer(self): | ||
| with fluid.dygraph.guard(): | ||
| mySuperlayer = MySuperLayer() | ||
| self.assertTrue(len(mySuperlayer.sublayers()) == 3) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 测试下include_self=False的情况
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 这个参数默认就是falsed
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 增加了测试 |
||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| paddle.enable_static() | ||
| unittest.main() | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
mylayer -> _mylayer ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done, thx