# tfr.keras.model.Scorer

<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/model.py#L668-L710) |

Interface for scorer.

The `Scorer` class is an abstract class to implement `score` in `ModelBuilder`
in tfr.keras.

To be implemented by subclasses:

- `__call__()`: Contains the logic to score based on the context and example features.

Example subclass implementation:

    class SimpleScorer(Scorer):

      def __call__(self, context_features, example_features, mask):
        x = tf.concat([tensor for tensor in example_features.values()], -1)
        return tf.keras.layers.Dense(1)(x)

## Methods

### `__call__`

[View source](https://github.com/tensorflow/ranking/blob/v0.5.3/tensorflow_ranking/python/keras/model.py#L690-L710)

    @abc.abstractmethod
    __call__(
        context_features: https://www.tensorflow.org/ranking/api_docs/python/tfr/keras/model/TensorDict,
        example_features: https://www.tensorflow.org/ranking/api_docs/python/tfr/keras/model/TensorDict,
        mask: tf.Tensor
    ) -> Union[TensorLike, TensorDict]

Scores all examples given context and returns logits.

<br />

<br />

<br />

| Args ||
|---|---|
| `context_features` | maps from context feature keys to \[batch_size, feature_dims\]-tensors of preprocessed context features. |
| `example_features` | maps from example feature keys to \[batch_size, list_size, feature_dims\]-tensors of preprocessed example features. |
| `mask` | \[batch_size, list_size\]-tensor of mask for valid examples. |

<br />

<br />

<br />

<br />

| Returns ||
|---|---|
| A \[batch_size, list_size\]-tensor of logits or a dict mapping task name to logits in the multi-task setting. ||

<br />