Upscaling a sigmoid result?

705 Views Asked by At

I'm confused about how to upscale a sigmoid result the right way. for example the input for my NN is between 0,10. I scale this to be between -4,4 as the active input range for sigmoid and i get a result of lets say 0.83201. Now i want to rescale this back to between 0,10.

I thought the inverse of sigmoid was logit but funny stuff happens when i use this:

float u = sig.LogSigmoid(sig.InputScaler(3,0f,10f,-4f,4f));
Debug.Log(-Mathf.Log(u/(1-u)));

results in: 1.6. while

float u = sig.LogSigmoid(sig.InputScaler(4,0f,10f,-4f,4f));
Debug.Log(-Mathf.Log(u/(1-u)));

results in: 0.8.

EDIT: Ok after some fiddling, i found that the Logit does work only it returns my scaled input :-). so for sigmoid + downscaling:

float u = sig.LogSigmoid(sig.InputScaler(6,0f,10f,-4f,4f));

the following logit + upscaling worked perfect:

Debug.Log(sig.InputScaler(-Mathf.Log((1-u)/u),-4f,4f,0f,10f));

InputScaler being:

public float InputScaler(float x, float minFrom, float maxFrom, float minTo, float maxTo)
{
    float t = (((x-minFrom)*(maxTo-minTo))/(maxFrom-minFrom))+minTo;
    return t;
}
1

There are 1 best solutions below

2
On BEST ANSWER

To rescale the output of the sigmoid (which is in the range [0,1]) to [0,10] you could of course generically use sig.InputScale(u,0f,1f,0f,10f) but of course in this case the scaling is as easy as u*10f.

However, I do not understand why you speak about the inverse sigmoid. If you want to rescale the output of a function, you never need the inverse function.

On the other hand, if you were instead trying to invert the sigmoid inclusive the input scaling, then you need to scale back the output of the logit from [-4,4] to [0,10]: I.e. sig.InputScale(Mathf.Log(u/(1-u)),-4f,4f,0f,10f).