How to do Cohen Kappa Quadratic Loss in Tensorflow 2.0?
问题 I'm trying to create the loss function according to: How can I specify a loss function to be quadratic weighted kappa in Keras? But in tensorflow 2.0: tf.contrib.metrics.cohen_kappa No longer exists. Is there an alternative? 回答1: def kappa_loss(y_pred, y_true, y_pow=2, eps=1e-10, N=4, bsize=256, name='kappa'): """A continuous differentiable approximation of discrete kappa loss. Args: y_pred: 2D tensor or array, [batch_size, num_classes] y_true: 2D tensor or array,[batch_size, num_classes] y