#DeepLearning #Softmax #Argmax
Softmax and Argmax
- argmax
- softmax
Argmax
The argmax function returns the index of the maximum value in a given array or function. Mathematically, it can be represented as:
- 简单的说, 有一个数组
, argmax 会找到最大数字的下标
[!example]+ 给定数组如下
- argmax 将会返回3,因为最大值
在数组的下标是3
- 优点在于可以简单直接的解释输出
- 缺点在与argmax不可导,不可用于训练模型
所以一般可以用argmax输出,softmax训练
Softmax
The softmax function converts a vector of values into probabilities, such that the sum of all probabilities equals 1. The formula for softmax is:
Where:
is the element of the input vector. represents the exponential of the element. The denominator is the sum of the exponentials of all elements in the input vector.
这种转换在多类分类问题中特别有用,其中softmax函数的输出表示不同类的预测概率。
[!example]+ 给定数组如下
- softmax函数将返回一个概率向量: