3

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

MNM
  • 2,673
  • 6
  • 38
  • 73
  • 2
    e is a mathematical constant see [here](https://en.wikipedia.org/wiki/E_(mathematical_constant)). e^x is basically mathematical syntactic sugar for the exp(x) function but they mean the same thing. – jodag Jan 22 '20 at 05:14
  • so your are saying the exp() is e here? Is that what .exp(-x) does – MNM Jan 22 '20 at 05:20
  • 2
    x is just a variable so exp() = e^ its just a different representation of the same thing. – jodag Jan 22 '20 at 05:20
  • Seeing you were first could you make your explanation the answer and I will accept it. Thank you @jodag – MNM Jan 22 '20 at 05:23
  • 3
    It's fine go ahead and accept Dishin's – jodag Jan 22 '20 at 05:24

1 Answers1

4

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

jodag
  • 19,885
  • 5
  • 47
  • 66
Dishin H Goyani
  • 7,195
  • 3
  • 26
  • 37
  • 1
    so the parameter that you plug into will be x correct. So e does not have to be defined. – MNM Jan 22 '20 at 05:22