About code implementation of calculating slope rate
#35
by
lcon730
- opened
Hi, thanks for your work. I was studying the codes and find the part for calculating slope rate a bit difficult to understand.
The get_slopes_power_of_2
implementation looks like a complex version of Alibi? I wonder if there is any special reason for these lines (why using log2 and exponential calculation here)? Mathematically this formula for base
should just be equivalent to 2 ** (-8/n)
. I run a simple test and seems the following two are the same (with some precision error).
def get_slopes_power_of_2(n):
start = 2 ** (-(2 ** -(math.log2(n) - 3)))
ratio = start
return [start * ratio ** i for i in range(n)]
def my(n):
return [(0.5) ** (8*(i+1)/n) for i in range(n)]
Thanks.