Fix get_numpy_tensor for paddle.Tensor.__rpow__ #519
Merged
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.
设MAX是dtype支持的最大值,B是常数底,不妨设B>1
则
y = B^x
dy/dx = y*lnB
为了保证不溢出,需要y<MAX,dy/dx <MAX
令y = MAX,则
B^x=MAX
xlnB=lnMAX
x = lnMAX/lnB
令dy/dx = MAX
则 x = ln(MAX/lnB)/lnB
注:
当0<B<1时,可以通过1/B限制,因为此时y和dy/dx取得最大值的时机是x取最小值,x的最小值和最大值互为相反数,所以这与令B变为倒数是等价的