ML 002 — Sigmoid Function

Source: Deep Learning on Medium


import numpy as np
import matplotlib.pyplot as plt
x = np.arange(-10, 10, 0.01)
# sigmoid
y = 1 / (1 + np.exp(-x))
# sigmoid derivative
y_d = y * (1 - y)
plt.style.use('seaborn-darkgrid')
fig = plt.figure(figsize=[6, 3])
fig.add_subplot(121)
plt.plot(x, y)
fig.add_subplot(122)
plt.plot(x, y_d)
fig.savefig('x.png', dpi=200)
plt.show()