DIFFERENCE BETWEEN SOFTMAX FUNCTION AND SIGMOID FUNCTION

二者主要的区别见于,

sigmoid function vs softmax function-LMLPHP

  • softmax 用于多分类,sigmoid 则主要用于二分类;
⎧⎩⎨⎪⎪⎪⎪⎪⎪⎪⎪F(Xi)=11+exp(−Xi)=exp(Xi)exp(Xi)+1F(Xi)=exp(Xi)∑kj=0exp(Xj),i=0,1,…,k
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()

sigmoid function vs softmax function-LMLPHP

05-24 05:51