Sigmoid function returning 2

Question:

I just started learning about neural networks and I’m using the sigmoid function.

Here’s the implementation :

def sigmoid(x):
return 1/1+(np.exp(-x))

then I have my network :

def make_predictions2(previousPrice, currentPrice, weight1, weight2, weight3, bias):
n11 = np.dot(previousPrice, weight1) + np.dot(currentPrice, weight2) + bias
n21 = np.dot(n11, weight3) + bias
n31 = sigmoid(n21)
return n31[0]

the problem is that the function is returning 2.0, but sigmoid is only supposed to return numbers between 0 and 1
Am I missing something obvious ?

Asked By: Lalaryk

||

Answers:

As you can see in here, that definition of the sigmoid function is wrong. Instead of

def sigmoid(x): 
  return 1/1+(np.exp(-x))

you should use the following definition:

def sigmoid(x): 
  return 1/(1+np.exp(-x))
Answered By: Domenico
Categories: questions Tags: ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.