官方说明书的例子其实特别简单明了,

y_true = [[0., 1.], [0., 0.]]
y_pred = [[0.6, 0.4], [0.4, 0.6]]
# Using 'auto'/'sum_over_batch_size' reduction type.
bce = tf.keras.losses.BinaryCrossentropy()
bce(y_true, y_pred).numpy()

从这个例子也可以看出,BinaryCrossentropy是支持one-hot编码的。

相关文章:

猜你喜欢
  • 2021-08-19
  • 2021-05-09
  • 2021-10-21
  • 2022-12-23
  • 2021-12-01
相关资源
相似解决方案