https://qiita.com/yohiro/items/04984927d0b455700cd1 Continued
matplotlib is a graph drawing library. It seems that he often uses pyplot. numpy is a numerical calculation library. You will be able to draw mathematical graphs by combining these two.
import matplotlib.pyplot as plt
import numpy as np
If $ y = 2x + 1 $
x = np.arange(0, 10, 0.1) #0 to 10 0.Create 1-step list x
y = 2*x + 1 #x 2x for each element+Create y as a map of 1
plt.plot(x, y) # (x, y)Draw a graph of
plt.show() #graph display
You can draw the following graph by writing
A function that draws the following curve. The expression is represented by $ y = \ frac {1} {1 + e ^ x} $.
It has a high affinity with the property of neurons that "fires when the input exceeds the threshold", and is often used as an activation function (probably). The implementation example by Python is as follows.
import math
def sigmoid(a):
return (1.0 / (1.0 + math.exp(-a)))
Recommended Posts