Losses

Collection of Ivy loss functions.

ivy.neural_net_functional.losses.binary_cross_entropy(true, pred, epsilon=1e-07)[source]

Computes the binary cross entropy loss.

Parameters
  • true (array) – true labels

  • pred (array) – Predicted labels

  • epsilon (float, optional) – small constant to add to log functions, default is 1e-7

Returns

The binary cross entropy loss array.

ivy.neural_net_functional.losses.cross_entropy(true, pred, axis=- 1, epsilon=1e-07)[source]

Computes cross entropy between predicted and true discrete distrubtions.

Parameters
  • true (array) – True labels

  • pred (array) – predicted labels.

  • axis (int, optional) – The class dimension, default is -1.

  • epsilon (float, optional) – small constant to add to log functions, default is 1e-7

Returns

The cross entropy loss

ivy.neural_net_functional.losses.sparse_cross_entropy(true, pred, axis=- 1, epsilon=1e-07)[source]

Computes sparse cross entropy between logits and labels.

Parameters
  • true (array) – True labels as logits.

  • pred (array) – predicted labels as logits.

  • axis (int, optional) – The class dimension, default is -1.

  • epsilon (float, optional) – small constant to add to log functions, default is 1e-7

Returns

The sparse cross entropy loss