演示代码
import io
import sys
sys.stdout = io.TextIOWrapper(sys.stdout.buffer, encoding='utf-8')
import numpy as np
import matplotlib.pyplot as plt
print('_hello,inited!')
def step(x):
return np.array(x>0,dtype=np.int)
def sigmoid(x):
return 1 / (1 + np.exp(-x))
def reLU(x):
return np.maximum(0, x)
x = np.arange(-5.0, 5.0, 0.1)
y1 = sigmoid(x)
y2 = step(x)
y3 = reLU(x)
plt.plot(x,y1,label='sigmoid')
plt.plot(x,y2,label='step',linestyle='--')
plt.plot(x,y3,label='reLU')
plt.title('sigmoid & step & reLU')
plt.ylim(-0.1, 1.1)
plt.legend()
plt.show()
结果
softmax函数 :
softmax 函数的输出是