Sigmoid Activation Function

The sigmoid function is one of the most common and widely activation function. It takes an input of any value within the domain of inputs and returns a value between 0 and 1.

Mathematically: $$ f(x) = \frac{1}{ 1 + e^{-x}} $$

Below, we implement the sigmoid activation function in pytorch and visualize the output

import torch
import matplotlib.pyplot as plt

# Initializing inputs and applying sigmoid function
x_inputs = torch.arange(-10., 10., 1)
y_outputs = y = torch.sigmoid(x_inputs)

plt.plot(x_inputs, y_outputs)
plt.title("Sigmoid Function, x[-10, 10]")    
Sigmoid Function