# tfr.keras.losses.get

<br />

|---|
| [![](https://www.tensorflow.org/images/GitHub-Mark-32px.png) View source on GitHub](https://github.com/tensorflow/ranking/blob/v0.5.3/tensorflow_ranking/python/keras/losses.py#L50-L109) |

Factory method to get a ranking loss class.

    tfr.keras.losses.get(
        loss: str,
        reduction: tf.losses.Reduction = tf.losses.Reduction.AUTO,
        lambda_weight: Optional[losses_impl._LambdaWeight] = None,
        name: Optional[str] = None,
        **kwargs
    ) -> tf.keras.losses.Loss

<br />

<br />

<br />

| ## Args ||
|---|---|
| `loss` | (str) An attribute of `RankingLossKey`, defining which loss object to return. |
| `reduction` | (enum) An enum of strings indicating the loss reduction type. See type definition in the `tf.compat.v2.losses.Reduction`. |
| `lambda_weight` | (losses_impl._LambdaWeight) A lambda object for ranking metric optimization. |
| `name` | (optional) (str) Name of loss. |
| `**kwargs` | Keyword arguments for the loss object. |

<br />

<br />

<br />

<br />

| ## Returns ||
|---|---|
| A ranking loss instance. See `_RankingLoss` signature for more details. ||

<br />

<br />

<br />

<br />

| ## Raises ||
|---|---|
| `ValueError` | If loss_key is unsupported. |

<br />