Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Pytorch Sigmoid Function what is e

I have a question on setting up the sigmoid function in pytroch.

So I define it as this

# Sigmoid function
def sigmoid(x):
    return 1/(1 + torch.exp(-x))

But then looking at the sigmoid function from here http://mathworld.wolfram.com/SigmoidFunction.html

The sigmoid should be defined as

y = 1/(1 + e^-x)

I see the 1/(1+ part but I don't get the e^-x part. Can someone explain why

torch.exp(-x) == e^-x 

What is e here? Is that the tensor. But i thought that x was the tensor

like image 326
MNM Avatar asked Feb 20 '26 07:02

MNM


1 Answers

Here e is the exponential constant e and torch.exp(-x) == e^-x

  • torch.exp(x) returns e^x
like image 64
Dishin H Goyani Avatar answered Feb 23 '26 16:02

Dishin H Goyani