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__

BinaryCrossentropy.__init__(
  reduction='mean',
  name=None
)[source]

Create a BinaryCrossentropy criterion.

Parameters:
  • reduction ({'none', 'sum', 'mean', 'valid'}, optional) The reduction method.
  • name (str, optional) The operation name.

Methods

__call__

Loss.__call__(
  y_true,
  y_pred
)[source]

Compute the defined loss function.

Parameters:
Returns:

dragon.Tensor The loss.