Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Inverse Sigmoid Function in Python for Neural Networks?

Tags:

python

I am trying to implement an Inverse Sigmoid function to the last layer of my Convolutional Neural Network? I am trying to build the network in Pytorch and I want to take the output from the last Convolutional Layer and then apply Inverse Sigmoid Function to it.

I have read that the logit function is the opposite of sigmoid function and I tried implementing it but its not working. I used the logit function from the scipy library and used it in the function.

def InverseSigmoid(self, x):

        x = logit(x)
        return x
like image 499
Shubh_20 Avatar asked Dec 07 '25 10:12

Shubh_20


1 Answers

Sigmoid is just 1 / (1 + e**-x). So if you want to invert it you can just -ln((1 / x) - 1). For numerical stability purposes, you can also do -ln((1 / (x + 1e-8)) - 1). This is the inverse function of sigmoid, implementation is straightforward.

like image 116
abe Avatar answered Dec 09 '25 23:12

abe



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!