import tensorflow as tf
铰链损失函数
它可用于“最大间隔(max-margin)”分类,其最著名的应用是作为SVM的损失函数。
二分类
多分类
y_true = [[0, 1], [0, 0]]y_pred = [[0.6, 0.4], [0.4, 0.6]]# Using 'auto'/'sum_over_batch_size' reduction type.h = tf.keras.losses.CategoricalHinge()h(y_true, y_pred).numpy()
1.4000001