DIFFERENCE BETWEEN SOFTMAX FUNCTION AND SIGMOID FUNCTION
二者主要的区别见于,
- softmax 用于多分类,sigmoid 则主要用于二分类;
import numpy as np
import matplotlib.pyplot as plt
def sigmoid(inputs):
return np.exp(inputs)/(np.exp(inputs)+1)
def softmax(inputs):
return np.exp(inputs)/sum(np.exp(inputs))
x = range(21)
sigmoid_x = sigmoid(x)
softmax_x = softmax(x)
plt.plot(x, sigmoid_x, x , softmax_x, lw=2)
plt.legend(['sigmoid', 'softmax'])
plt.show()