The sigmoid function is a common activation function used in neural networks. It is also known as the logistic function.
| x | |
|---|---|
| -1 | 0.268941 |
| 0 | 0.5 |
| 1 | 0.731059 |
| 2 | 0.880797 |
| 3 | 0.952574 |
import numpy as np
def sigmoid(x):
return 1 / (1 + np.exp(-x))
sigmoid <- function(x) {
return (1 / (1 + exp(-x)))
}
function sigmoid(x)
return 1 / (1 + exp(-x))
end
import tensorflow as tf
x = tf.constant([-1, 0, 1, 2, 3], dtype=tf.float32)
y = tf.nn.sigmoid(x)
print(y)
import torch
x = torch.tensor([-1, 0, 1, 2, 3], dtype=torch.float32)
y = torch.sigmoid(x)
print(y)
from scipy.special import expit
x = np.array([-1, 0, 1, 2, 3])
y = expit(x)
print(y)