API Documentation#
TensorFlow Models#
Ranking Model Constructors#
|
Create a model using the architecture proposed in DCN V2: Improved Deep & Cross Network [1]. |
|
DLRM-model architecture. |
Retrieval Model Constructors#
|
Builds a matrix factorization model. |
|
Builds the Two-tower architecture, as proposed in [1]. |
|
Build the Youtube-DNN retrieval model. |
Input Block Constructors#
|
The entry block of the model to process input features from a schema. |
|
Input block for continuous features. |
|
|
|
Input block for embedding-lookups for categorical features. |
|
Input block for embedding-lookups for categorical features. This module produces 3-D tensors, this is useful for sequential models like transformers. :param feature_config: This specifies what TableConfig to use for each feature. For shared embeddings, the same TableConfig can be used for multiple features. :type feature_config: Dict[str, FeatureConfig] :param item_id: The name of the feature that's used for the item_id. :type item_id: str, optional :param padding_idx: The symbol to use for padding. :type padding_idx: int :param pre: Transformations to apply on the inputs when the module is called (so before call). :type pre: Union[str, TabularTransformation, List[str], List[TabularTransformation]], optional :param post: Transformations to apply on the inputs after the module is called (so after call). :type post: Union[str, TabularTransformation, List[str], List[TabularTransformation]], optional :param aggregation: Aggregation to apply after processing the call-method to output a single Tensor. |
Model Building Block Constructors#
|
Builds the DLRM architecture, as proposed in the following `paper https://arxiv.org/pdf/1906.00091.pdf`_ [1]_. |
|
A block that applies a multi-layer perceptron to the input. |
|
This block provides a way to create high-order feature interactions |
|
Builds the Two-tower architecture, as proposed in the following `paper https://doi.org/10.1145/3298689.3346996`_ [Xinyang19]. |
|
Returns a block for Matrix Factorization, which created the user and item embeddings based on the schema and computes the dot product between user and item L2-norm embeddings |
|
Modeling Prediction Task Constructors#
|
Creates Multi-task prediction Blocks from schema |
|
Base-class for prediction tasks. |
|
Prediction task for binary classification. |
|
Prediction task for multi-class classification. |
|
Prediction task for regression-task. |
|
Prediction-task for item-retrieval. |
Model Pipeline Constructors#
|
The SequentialLayer represents a sequence of Keras layers. It is a Keras Layer that can be used instead of tf.keras.layers.Sequential, which is actually a Keras Model. In contrast to keras Sequential, this layer can be used as a pure Layer in tf.functions and when exporting SavedModels, without having to pre-declare input and output shapes. In turn, this layer is usable as a preprocessing layer for TF Agents Networks, and can be exported via PolicySaver. Usage::. |
|
Merge multiple layers or TabularModule's into a single output of TabularData. |
|
Multi-task prediction block. |
|
A block that applies a dense residual block to the input. |
|
|
|
|
|
Layer that's specialized for tabular-data by integrating many often used operations. |
|
Transformation that filters out certain features from TabularData." |
Masking Block Constructors#
Transformation Block Constructors#
|
Expand dims of selected input tensors. Example:: inputs = { "cont_feat1": tf.random.uniform((NUM_ROWS,)), "cont_feat2": tf.random.uniform((NUM_ROWS,)), "multi_hot_categ_feat": tf.random.uniform( (NUM_ROWS, 4), minval=1, maxval=100, dtype=tf.int32 ), } expand_dims_op = tr.ExpandDims(expand_dims={"cont_feat2": 0, "multi_hot_categ_feat": 1}) expanded_inputs = expand_dims_op(inputs). |
|
Applies Stochastic replacement of sequence features |
|
Converts a Tensor to TabularData by converting it to a dictionary. |
Multi-Task Block Constructors#
|
|
|
Data Loader Customization Constructor#
Metrics#
|
|
|
|
|
Sampling#
|
|
|
Provides in-batch sampling [1]_ for two-tower item retrieval models. |
|
Provides a popularity-based negative sampling for the softmax layer to ensure training efficiency when the catalog of items is very large. |
Losses#
|
Extends tf.keras.losses.SparseCategoricalCrossentropy by making from_logits=True by default (in this case an optimized softmax activation is applied within this loss, you should not include softmax activation manually in the output layer). |
|
Extends tf.keras.losses.SparseCategoricalCrossentropy by making from_logits=True by default (in this case an optimized softmax activation is applied within this loss, you should not include softmax activation manually in the output layer). |
|
The Bayesian Personalised Ranking (BPR) pairwise loss [1]_ |
|
The BPR-max pairwise loss proposed in [1]_ |
|
Pairwise hinge loss, as described in [1]_: max(0, 1 + r_uj - r_ui)), where r_ui is the score of the positive item and r_uj the score of negative items. |
|
Pairwise log loss, as described in [1]_: log(1 + exp(r_uj - r_ui)), where r_ui is the score of the positive item and r_uj the score of negative items. |
|
The TOP pairwise loss proposed in [1]_ |
|
The TOP1-max pairwise loss proposed in [1]_ |
|
An adapted version of the TOP pairwise loss proposed in [1]_, but following the current GRU4Rec implementation [2]_. |
Schema Functions#
|
|
|
|
|
|
|
|
Filters out entries from input_dict, returns a dictionary where every entry corresponds to a column in the schema |
|
|
|
|
|
|
Provides a heristic (from Google) that suggests the embedding sizes as a function (forth root) of categorical features cardinalities, obtained from the schema. |
|
Provides a heuristic (from Google) that suggests the embedding dimension as a function (forth root) of the feature cardinality. |
Utilities#
Miscellaneous Utility Functions#
Analyses the feature map config and returns the name of the label feature (e.g. |
|
|
Analyses the feature map config and returns the name of the label feature (e.g. |
A context manager that prints the execution time of the block it manages |
|
Recursively finds size of objects |
|
Util function to load NVTabular Dataset from disk |
Registry Functions#
Default name for a class or function. |
|
|
Dict-like class for managing function registrations. |
Creates a help string for names_list grouped by prefix. |