![]() |
Computes metrics for across top K candidates surfaced by a retrieval model.
tfrs.metrics.FactorizedTopK(
candidates: Union[tfrs.layers.factorized_top_k.TopK
, tf.data.Dataset],
metrics: Optional[Sequence[tf.keras.metrics.Metric]] = None,
k: int = 100,
name: Text = 'factorized_top_k'
) -> None
Used in the notebooks
Used in the tutorials |
---|
The default metric is top K categorical accuracy: how often the true candidate is in the top K candidates for a given query.
Args | |
---|---|
candidates
|
A layer for retrieving top candidates in response to a query, or a dataset of candidate embeddings from which candidates should be retrieved. |
metrics
|
The metrics to compute. If not supplied, will compute top-K categorical accuracy metrics. |
k
|
The number of top scoring candidates to retrieve for metric evaluation. |
name
|
Optional name. |
Methods
call
call(
inputs, **kwargs
)
This is where the layer's logic lives.
Note here that call()
method in tf.keras
is little bit different
from keras
API. In keras
API, you can pass support masking for
layers as additional arguments. Whereas tf.keras
has compute_mask()
method to support masking.
Arguments | |
---|---|
inputs
|
Input tensor, or list/tuple of input tensors. |
**kwargs
|
Additional keyword arguments. Currently unused. |
Returns | |
---|---|
A tensor or list/tuple of tensors. |
reset_states
reset_states() -> None
Resets the metrics.
result
result() -> List[tf.Tensor]
Returns a list of metric results.
update_state
update_state(
query_embeddings: tf.Tensor,
true_candidate_embeddings: tf.Tensor
) -> tf.Operation
Updates the metrics.
Args | |
---|---|
query_embeddings
|
[num_queries, embedding_dim] tensor of query embeddings. |
true_candidate_embeddings
|
[num_queries, embedding_dim] tensor of embeddings for candidates that were selected for the query. |
Returns | |
---|---|
Update op. Only used in graph mode. |