tfr.keras.model.PreprocessorWithSpec
Stay organized with collections
Save and categorize content based on your preferences.
Preprocessing inputs with provided spec.
Inherits From: Preprocessor
tfr.keras.model.PreprocessorWithSpec(
preprocess_spec: Optional[Dict[str, Callable[[Any], Any]]] = None,
default_value_spec: Optional[Dict[str, float]] = None
)
Transformation including KPL or customized transformation like log1p can be
defined and passed in preprocess_spec
with the following example usage:
preprocess_spec = {
**{name: lambda t: tf.math.log1p(t * tf.sign(t)) * tf.sign(t)
for name in example_feature_spec.keys()},
**{name: tf.reduce_mean(
tf.keras.layers.Embedding(input_dim=10, output_dim=4)(x), axis=-2)
for name in context_feature_spec.keys()}
}
preprocessor = PreprocessorWithSpec(preprocess_spec)
Args |
preprocess_spec
|
maps a feature key to a callable to preprocess a feature.
Only include those features that need preprocessing.
|
default_value_spec
|
maps a feature key to a default value to convert a
RaggedTensor to Tensor. Default to 0. if not specified.
|
Methods
__call__
View source
__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
]
See Preprocessor
.
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.
[[["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."],[],[]]