Softmax给出奇怪的结果

时间:2019-10-11 16:30:00

标签: python python-3.x softmax

如果我运行此命令:

probs = np.array( [683.8336792, 861.69769287, 981.83361816, 834.32391357] )
softs = softmax([probs])[0]
print(softs)

软件总是大幅度倾斜到最大的981.83数字-知道为什么吗?

[3.80426623e-130 6.69315016e-053 1.00000000e+000 8.65663825e-065]

softmax函数来自sklearn软件包

def softmax(X, copy=True):

    if copy:
        X = np.copy(X)
    max_prob = np.max(X, axis=1).reshape((-1, 1))
    X -= max_prob
    np.exp(X, X)
    sum_prob = np.sum(X, axis=1).reshape((-1, 1))
    X /= sum_prob
    return X

0 个答案:

没有答案