Return zero gradient for zero norm function.#393
Open
bewantbe wants to merge 1 commit intoHIPS:masterfrom
Open
Return zero gradient for zero norm function.#393bewantbe wants to merge 1 commit intoHIPS:masterfrom
bewantbe wants to merge 1 commit intoHIPS:masterfrom
Conversation
Fix issues HIPS#370 Now the gradient at zero (origin) point of np.linalg.norm() is the same as np.abs, which is zero, one of its subgradient. For second order gradients, mathematically they should be +infinity, but here when ord>=2 it returns 0 (same as np.abs()), when 1<ord<2, it is NaN with plenty of warnings, which should be enough to prevent user from doing that.
86820fd to
2f6cc22
Compare
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.
Fix issues #370
Now the gradient at zero (origin) point of np.linalg.norm() is the same as np.abs, which is zero, one of its subgradient.
For second order gradients, mathematically they should be +infinity, but
here when ord>=2 it returns 0 (same as np.abs()), when 1<ord<2, it is
NaN with plenty of warnings, which should be enough to prevent user from
doing that.
Also note that when x is complex number, the gradient of the norm seems wrong according to your document, there should be a conj(x) in the expression, see also the comments in the committed code.