tfr.keras.model.Preprocessor
Stay organized with collections
Save and categorize content based on your preferences.
Interface for feature preprocessing.
The Preprocessor
class is an abstract class to implement preprocess
in
ModelBuilder
in tfr.keras.
To be implemented by subclasses:
__call__()
: Contains the logic to preprocess context and example inputs.
Example subclass implementation:
class SimplePreprocessor(Preprocessor):
def __call__(self, context_inputs, example_inputs, mask):
context_features = {
name: tf.math.log1p(
tf.abs(tensor)) for name, tensor in context_inputs.items()
}
example_features = {
name: tf.math.log1p(
tf.abs(tensor)) for name, tensor in example_inputs.items()
}
return context_features, example_features
Methods
__call__
View source
@abc.abstractmethod
__call__(
context_inputs: tfr.keras.model.TensorDict
,
example_inputs: tfr.keras.model.TensorDict
,
mask: tf.Tensor
) -> Tuple[tfr.keras.model.TensorDict
, tfr.keras.model.TensorDict
]
Invokes the Preprocessor
instance.
Args |
context_inputs
|
maps context feature keys to tf.keras.Input .
|
example_inputs
|
maps example feature keys to tf.keras.Input .
|
mask
|
[batch_size, list_size]-tensor of mask for valid examples.
|
Returns |
A tuple of two dicts which map the context and example feature keys to
the corresponding tf.Tensor s.
|
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."],[],[]]