"sparse cross entropy loss"中稀疏的含义?

Meaning of sparse in "sparse cross entropy loss"?

read 来自文档:

tf.keras.losses.SparseCategoricalCrossentropy(
    from_logits=False, reduction="auto", name="sparse_categorical_crossentropy"
)

Computes the crossentropy loss between the labels and predictions.

Use this crossentropy loss function when there are two or more label classes. We expect labels to be provided as integers. If you want to provide labels using one-hot representation, please use CategoricalCrossentropy loss. There should be # classes floating point values per feature for y_pred and a single floating point value per feature for y_true.

为什么这叫做稀疏分类交叉熵?如果有的话,我们正在提供更紧凑的 class 标签编码(整数与单热向量)。

Keras 开发人员可能最好地回答了为什么这样称呼它。但是,请注意,这种稀疏交叉熵 适用于“稀疏标签”,其中只有一个值为 1,所有其他值为 0(如果标签表示为向量而不是只是一个索引)。

另一方面,一般 CategoricalCrossentropy 也适用于非单热目标,即任何概率分布。这些值只需要 介于 0 和 1 之间并且总和为 1。这往往会被遗忘,因为单热目标的用例在当前的 ML 应用程序中非常普遍。

我认为这是因为整数编码比单热编码更紧凑,因此更适合编码稀疏二进制数据。换句话说,整数编码 = 更好的稀疏二进制数据编码。

当您有许多可能的标签(和样本)时,这会很方便,在这种情况下,单热编码比每个示例的简单整数要浪费得多。