BinaryCrossentropy¶
- class
dragon.vm.tensorflow.keras.losses.
BinaryCrossentropy
(
reduction='mean',
name=None
)[source]¶ A criterion to compute the binary cross entropy with contiguous targets.
The CrossEntropy function is defined as:
\[\text{CrossEntropy}(p_{t}) = -\log(p_{t}) \]Examples:
criterion = tf.keras.cost.BinaryCrossentropy() y_true = tf.constant([0., 0., 1., 1.]) y_pred = tf.constant([0.1, 0.2, 0.3, 0.4]) print(criterion(y_true, y_pred)) # 0.65247655
__init__¶
Methods¶
__call__¶
Loss.
__call__
(
y_true,
y_pred
)[source]Compute the defined loss function.
- Parameters:
- y_true (dragon.Tensor) – The ground-truth tensor.
- y_pred (dragon.Tensor) – The logits tensor.
- Returns:
dragon.Tensor – The loss.