-
Notifications
You must be signed in to change notification settings - Fork 5.9k
expose AppendBackward of ProgramDesc to python #4699
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
Changes from 2 commits
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 |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| import unittest | ||
|
|
||
| import paddle.v2.framework.core as core | ||
| from paddle.v2.framework.graph import g_program | ||
|
|
||
|
|
||
|
|
@@ -31,6 +33,21 @@ def test_program(self): | |
| self.assertEqual(1, b.idx) | ||
| self.assertEqual(0, b.parent_idx) | ||
|
|
||
| def test_backward(self): | ||
| prog = core.ProgramDesc.__create_program_desc__() | ||
| self.assertIsNotNone(prog) | ||
| block = prog.block(0) | ||
| self.assertIsNotNone(block) | ||
|
|
||
| sum_op_desc = block.append_op() | ||
| sum_op_desc.set_type("sum") | ||
| sum_op_desc.set_input("X", ["x1", "x2"]) | ||
| sum_op_desc.set_output("Out", ["out"]) | ||
|
|
||
| self.assertEqual(len(block.all_ops()), 1) | ||
| prog.backward(set()) | ||
| self.assertEqual(len(block.all_ops()), 3) | ||
|
||
|
|
||
|
|
||
| if __name__ == '__main__': | ||
| 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.
I think
append_backwardis a better name.backwardmeans the process that executes gradient op one by one, not append them.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