tfr.keras.model.Scorer
Stay organized with collections
Save and categorize content based on your preferences.
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
@abc.abstractmethod
__call__(
context_features: tfr.keras.model.TensorDict
,
example_features: tfr.keras.model.TensorDict
,
mask: tf.Tensor
) -> Union[TensorLike, TensorDict]
Scores all examples given context and returns logits.
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.
|
Returns |
A [batch_size, list_size]-tensor of logits or a dict mapping task name to
logits in the multi-task setting.
|
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.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
{"lastModified": "Last updated 2023-08-18 UTC."}
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2023-08-18 UTC."],[],[]]