tfr.keras.model.UnivariateScorer
Stay organized with collections
Save and categorize content based on your preferences.
Interface for univariate scorer.
Inherits From: Scorer
The UnivariateScorer
class is an abstract class to implement score
in
ModelBuilder
in tfr.keras with a univariate scoring function.
To be implemented by subclasses:
_score_flattened()
: Contains the logic to do the univariate scoring on
flattened context and example features.
Example subclass implementation:
class SimpleUnivariateScorer(UnivariateScorer):
def _score_flattened(self, context_features, example_features):
x = tf.concat([tensor for tensor in example_features.values()], -1)
return tf.keras.layers.Dense(1)(x)
Methods
__call__
View source
__call__(
context_features: tfr.keras.model.TensorDict
,
example_features: tfr.keras.model.TensorDict
,
mask: tf.Tensor
) -> Union[tf.Tensor, tfr.keras.model.TensorDict
]
See Scorer
.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2023-08-18 UTC.
[null,null,["Last updated 2023-08-18 UTC."],[],[],null,["# tfr.keras.model.UnivariateScorer\n\n\u003cbr /\u003e\n\n|-------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/ranking/blob/v0.5.3/tensorflow_ranking/python/keras/model.py#L713-L777) |\n\nInterface for univariate scorer.\n\nInherits From: [`Scorer`](../../../tfr/keras/model/Scorer)\n\nThe `UnivariateScorer` class is an abstract class to implement `score` in\n`ModelBuilder` in tfr.keras with a univariate scoring function.\n\nTo be implemented by subclasses:\n\n- `_score_flattened()`: Contains the logic to do the univariate scoring on flattened context and example features.\n\nExample subclass implementation: \n\n class SimpleUnivariateScorer(UnivariateScorer):\n\n def _score_flattened(self, context_features, example_features):\n x = tf.concat([tensor for tensor in example_features.values()], -1)\n return tf.keras.layers.Dense(1)(x)\n\nMethods\n-------\n\n### `__call__`\n\n[View source](https://github.com/tensorflow/ranking/blob/v0.5.3/tensorflow_ranking/python/keras/model.py#L755-L777) \n\n __call__(\n context_features: ../../../tfr/keras/model/TensorDict,\n example_features: ../../../tfr/keras/model/TensorDict,\n mask: tf.Tensor\n ) -\u003e Union[tf.Tensor, ../../../tfr/keras/model/TensorDict]\n\nSee `Scorer`."]]