Skip to content

Conversation

@zrr1999
Copy link
Contributor

@zrr1999 zrr1999 commented Aug 12, 2025

设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变为倒数是等价的

@paddle-bot
Copy link

paddle-bot bot commented Aug 12, 2025

Thanks for your contribution!

Copy link
Collaborator

@wanghuancoder wanghuancoder left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants