sparse_categorical_crossentropy 的标签平滑
Label Smoothing for sparse_categorical_crossentropy
根据 Tensorflow 文档,可以通过添加 label_smoothing 参数将标签平滑添加到 categorical_crossentropy。我的问题是稀疏分类交叉熵损失如何。此损失函数没有 label_smoothing 参数。
当我们使用稀疏分类交叉熵作为损失函数时,没有 label_smoothing 参数。
编写自己的损失函数很容易:
from tensorflow.keras.losses import categorical_crossentropy
def scce_with_ls(y, y_hat):
y = tf.one_hot(tf.cast(y, tf.int32), n_classes)
return categorical_crossentropy(y, y_hat, label_smoothing = 0.1)
根据 Tensorflow 文档,可以通过添加 label_smoothing 参数将标签平滑添加到 categorical_crossentropy。我的问题是稀疏分类交叉熵损失如何。此损失函数没有 label_smoothing 参数。
当我们使用稀疏分类交叉熵作为损失函数时,没有 label_smoothing 参数。
编写自己的损失函数很容易:
from tensorflow.keras.losses import categorical_crossentropy
def scce_with_ls(y, y_hat):
y = tf.one_hot(tf.cast(y, tf.int32), n_classes)
return categorical_crossentropy(y, y_hat, label_smoothing = 0.1)