# tf.contrib.losses.compute_weighted_loss

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/tensorflow/blob/v1.15.0/tensorflow/contrib/losses/python/losses/loss_ops.py#L84-L122) |

Computes the weighted loss. (deprecated)

    tf.contrib.losses.compute_weighted_loss(
        losses, weights=1.0, scope=None
    )

> [!WARNING]
> **Warning:** THIS FUNCTION IS DEPRECATED. It will be removed after 2016-12-30. Instructions for updating: Use tf.losses.compute_weighted_loss instead.

<br />

<br />

<br />

| ## Args ||
|---|---|
| `losses` | A tensor of size \[batch_size, d1, ... dN\]. |
| `weights` | A tensor of size \[1\] or \[batch_size, d1, ... dK\] where K \< N. |
| `scope` | the scope for the operations performed in computing the loss. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A scalar `Tensor` that returns the weighted loss. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If `weights` is `None` or the shape is not compatible with `losses`, or if the number of dimensions (rank) of either `losses` or `weights` is missing. |

<br />