Questions tagged [sigmoid]

A sigmoid function is a mathematical function having an "S" shape (sigmoid curve). Often, sigmoid function refers to the special case of the logistic function defined by the formula S ( t ) = 1 / (1 + e^-t)

Sigmoid function (Wikipedia)

212 questions
176
votes
15 answers

How to calculate a logistic sigmoid function in Python?

This is a logistic sigmoid function: I know x. How can I calculate F(x) in Python now? Let's say x = 0.458. F(x) = ?
Richard Knop
  • 73,317
  • 142
  • 374
  • 539
53
votes
2 answers

What is the difference between a sigmoid followed by the cross entropy and sigmoid_cross_entropy_with_logits in TensorFlow?

When trying to get cross-entropy with sigmoid activation function, there is a difference between loss1 = -tf.reduce_sum(p*tf.log(q), 1) loss2 = tf.reduce_sum(tf.nn.sigmoid_cross_entropy_with_logits(labels=p, logits=logit_q),1) But they are the…
23
votes
5 answers

Keras retrieve value of node before activation function

Imagine a fully-connected neural network with its last two layers of the following structure: [Dense] units = 612 activation = softplus [Dense] units = 1 activation = sigmoid The output value of the net is 1, but I'd like to know…
johk95
  • 833
  • 9
  • 26
22
votes
1 answer

Fit sigmoid function ("S" shape curve) to data using Python

I'm trying to fit a sigmoid function to some data I have but I keep getting:ValueError: Unable to determine number of fit parameters. My data looks like this: My code is: from scipy.optimize import curve_fit def sigmoid(x): return…
user88484
  • 573
  • 1
  • 3
  • 20
22
votes
3 answers

ReLU derivative in backpropagation

I am about making backpropagation on a neural network that uses ReLU. In a previous project of mine, I did it on a network that was using Sigmoid activation function, but now I'm a little bit confused, since ReLU doesn't have a derivative. Here's an…
Gergely Papp
  • 589
  • 1
  • 4
  • 9
17
votes
2 answers

Keras Binary Classification - Sigmoid activation function

I've implemented a basic MLP in Keras with tensorflow and I'm trying to solve a binary classification problem. For binary classification, it seems that sigmoid is the recommended activation function and I'm not quite understanding why, and how Keras…
Daniel Whettam
  • 305
  • 1
  • 2
  • 9
16
votes
1 answer

Binary classification with Softmax

I am training a binary classifier using Sigmoid activation function with Binary crossentropy which gives good accuracy around 98%. The same when I train using softmax with categorical_crossentropy gives very low accuracy (< 40%). I am passing the…
AKSHAYAA VAIDYANATHAN
  • 2,229
  • 5
  • 26
  • 45
12
votes
6 answers

optimal way of defining a numerically stable sigmoid function for a list in python

For a scalar variable x, we know how to write down a numerically stable sigmoid function in python: def sigmoid(x): if x >= 0: return 1. / ( 1. + np.exp(-x) ) else: return exp(x) / ( 1. + np.exp(x) ) For a list of scalars,…
RandomWalker
  • 443
  • 5
  • 9
12
votes
2 answers

sigmoid in python that can take scalar, vector or matrix

The following code is written in Octave Programming language g =1./(1+e.^-(z) It computes a sigmoid function and can take scalar, vector or Matrix. For example if I put the above into a function sigmoid(z), where z=0, the result will…
sunny
  • 573
  • 1
  • 8
  • 23
11
votes
3 answers

logistic / sigmoid function implementation numerical precision

in scipy.special.expit, logistic function is implemented like the following: if x < 0 a = exp(x) a / (1 + a) else 1 / (1 + exp(-x)) However, I have seen implementations in other languages/frameworks that simply do 1 / (1 +…
colinfang
  • 17,887
  • 11
  • 69
  • 146
6
votes
4 answers

Training MSE loss larger than theoretical maximum?

I am training a keras model whose last layer is a single sigmoid unit: output = Dense(units=1, activation='sigmoid') I am training this model with some training data in which the expected output is always a number between 0.0 and 1.0. I am…
oooliverrr
  • 98
  • 7
5
votes
2 answers

Sigmoid output - can it be interpreted as probability?

Sigmoid function outputs a number between 0 and 1. Is this a probability or is it merely a 'yes or no' depending on whether it's above or below 0.5? Minimal example: Cats vs dogs binary classification. 0 is cat, 1 is dog. Can I perform the…
Voy
  • 2,938
  • 1
  • 30
  • 43
5
votes
1 answer

finding a point on a sigmoidal curve in r

Here is a data set: df <- data.frame('y' = c(81,67,54,49,41,25), 'x' =c(-50,-30,-10,10,30,50)) So far, I know how to fit a sigmoidal curve and display it on screen: plot(df$y ~ df$x) fit <- nls(y ~ SSlogis(x, Asym, xmid, scal), data =…
B C
  • 310
  • 3
  • 15
5
votes
2 answers

Sigmoid function returns 1 for large positive inputs

I wrote the following function in Python to calculate sigmoid function of a scalar, vector or matrix. def sigmoid(z): sig = 1.0/(1.0 + np.exp(-z)) return sig For relatively large positive values of z, e^-z returns a very small value close…
Supratim Haldar
  • 1,976
  • 2
  • 12
  • 24
5
votes
5 answers

Compute e^x for float values in System Verilog?

I am building a neural network running on an FPGA, and the last piece of the puzzle is running a sigmoid function in hardware. This is either: 1/(1 + e^-x) or (atan(x) + 1) / 2 Unfortunately, x here is a float value (a real value in…
rohan32
  • 432
  • 1
  • 6
  • 16
1
2 3
14 15