Support backward of backward for Relu and add a new gradient checker by comparing theoretical and numerical Jacobian.#16862
Merged
qingqing01 merged 8 commits intoPaddlePaddle:developfrom Apr 23, 2019
Conversation
test=develop
3bd23f8 to
7c8818d
Compare
test=develop
| from paddle.fluid.backward import _append_grad_suffix_, _as_list | ||
|
|
||
|
|
||
| def _product(t): |
| Each Jacobian gradients is a 2-D array with shape [xi_size, yi_size]. | ||
|
|
||
| Args: | ||
| program (Program): a Program with forward pass. |
| eps = 0.005 | ||
| dtype = np.float64 | ||
|
|
||
| #x = layers.data('x', shape, False, dtype) |
wanghaoshuang
previously approved these changes
Apr 15, 2019
test=develop
6a395ae to
2be620a
Compare
Contributor
Author
|
@sneaxiy I have deleted Thanks! |
wanghaoshuang
previously approved these changes
Apr 16, 2019
test=develop
test=develop
…CI has decorators package.
… backward_of_backward test=develop
Contributor
Author
The unit testing failed since Python on Windows CI have a same python package. Rename decorators to decorator_helper. So change the Please help to review. Thanks! @chengduoZH @luotao1 @XiaoguangHu01 |
Contributor
|
@tianshuo78520a It seems #16944 don't fix this problem #16862 (comment) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
relu_grad_gradop).relu_grad_grad.Add
ReluDoubleGradMakerwhen registerrelu_grad:REGISTER_OPERATOR(relu_grad, ops::ActivationOpGrad, paddle::framework::SingleOpInplaceInToOut, ops::ReluDoubleGradMaker);Add a new gradient checker by comparing theoretical and numerical Jacobian.
grad_check.double_grad_check.Add gradients testing for
relu_grad_grad.fluid.backward.calc_gradientis used to append the backward pass, which is similar interface totf.gradients.For example:
Note, this PR doest not use macro to register double grad for activations since only add one for relu. If adding more in the future, will use macro for more general.