# tf.compat.v1.losses.add_loss

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v2.13.1/tensorflow/python/ops/losses/util.py#L174-L186) |

Adds a externally defined loss to the collection of losses.

    tf.compat.v1.losses.add_loss(
        loss, loss_collection=ops.GraphKeys.LOSSES
    )

<br />

<br />

<br />

| ## Args ||
|---|---|
| `loss` | A loss `Tensor`. |
| `loss_collection` | Optional collection to add the loss to. |

<br />