binary_crossentropy¶
dragon.vm.tensorflow.keras.losses.
binary_crossentropy
(
y_true,
y_pred,
reduction='valid'
)[source]¶Compute the binary cross entropy with contiguous targets.
The CrossEntropy function is defined as:
\[\text{CrossEntropy}(p_{t}) = -\log(p_{t}) \]Examples:
y_true = tf.constant([0., 0., 1., 1.]) y_pred = tf.constant([0.1, 0.2, 0.3, 0.4]) print(tf.keras.cost.binary_crossentropy(y_true, y_pred)) # 0.65247655
- Parameters:
- y_true (dragon.Tensor) – The ground truth tensor.
- y_pred (dragon.Tensor) – The logits tensor.
- reduction ({'none', 'sum', 'mean', 'valid'}, optional) – The reduction method.
- Returns:
dragon.Tensor – The output tensor.