tfrs.layers.feature_interaction.DotInteraction
Stay organized with collections
Save and categorize content based on your preferences.
Dot interaction layer.
tfrs.layers.feature_interaction.DotInteraction(
self_interaction: bool = False,
skip_gather: bool = False,
name: Optional[str] = None,
**kwargs
) -> None
See theory in the DLRM paper: https://arxiv.org/pdf/1906.00091.pdf,
section 2.1.3. Sparse activations and dense activations are combined.
Dot interaction is applied to a batch of input Tensors [e1,...,e_k] of the
same dimension and the output is a batch of Tensors with all distinct pairwise
dot products of the form dot(e_i, e_j) for i <= j if self self_interaction is
True, otherwise dot(e_i, e_j) i < j.
Attributes |
self_interaction
|
Boolean indicating if features should self-interact.
If it is True, then the diagonal enteries of the interaction matric are
also taken.
|
skip_gather
|
An optimization flag. If it's set then the upper triangle part
of the dot interaction matrix dot(e_i, e_j) is set to 0. The resulting
activations will be of dimension [num_features * num_features] from which
half will be zeros. Otherwise activations will be only lower triangle part
of the interaction matrix. The later saves space but is much slower.
|
name
|
String name of the layer.
|
Methods
call
View source
call(
inputs: List[tf.Tensor]
) -> tf.Tensor
Performs the interaction operation on the tensors in the list.
The tensors represent as transformed dense features and embedded categorical
features.
Pre-condition: The tensors should all have the same shape.
Args |
inputs
|
List of features with shapes [batch_size, feature_dim].
|
Returns |
activations
|
Tensor representing interacted features. It has a dimension
num_features * num_features if skip_gather is True, otherside
num_features * (num_features + 1) / 2 if self_interaction is True and
num_features * (num_features - 1) / 2 if self_interaction is False.
|
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 2024-04-26 UTC.
[null,null,["Last updated 2024-04-26 UTC."],[],[],null,["# tfrs.layers.feature_interaction.DotInteraction\n\n\u003cbr /\u003e\n\n|----------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| [View source on GitHub](https://github.com/tensorflow/recommenders/blob/v0.7.3/tensorflow_recommenders/layers/feature_interaction/dot_interaction.py#L22-L104) |\n\nDot interaction layer. \n\n tfrs.layers.feature_interaction.DotInteraction(\n self_interaction: bool = False,\n skip_gather: bool = False,\n name: Optional[str] = None,\n **kwargs\n ) -\u003e None\n\nSee theory in the DLRM paper: \u003chttps://arxiv.org/pdf/1906.00091.pdf,\u003e\nsection 2.1.3. Sparse activations and dense activations are combined.\nDot interaction is applied to a batch of input Tensors \\[e1,...,e_k\\] of the\nsame dimension and the output is a batch of Tensors with all distinct pairwise\ndot products of the form dot(e_i, e_j) for i \\\u003c= j if self self_interaction is\nTrue, otherwise dot(e_i, e_j) i \\\u003c j.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Attributes ---------- ||\n|--------------------|--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `self_interaction` | Boolean indicating if features should self-interact. If it is True, then the diagonal enteries of the interaction matric are also taken. |\n| `skip_gather` | An optimization flag. If it's set then the upper triangle part of the dot interaction matrix dot(e_i, e_j) is set to 0. The resulting activations will be of dimension \\[num_features \\* num_features\\] from which half will be zeros. Otherwise activations will be only lower triangle part of the interaction matrix. The later saves space but is much slower. |\n| `name` | String name of the layer. |\n\n\u003cbr /\u003e\n\nMethods\n-------\n\n### `call`\n\n[View source](https://github.com/tensorflow/recommenders/blob/v0.7.3/tensorflow_recommenders/layers/feature_interaction/dot_interaction.py#L53-L104) \n\n call(\n inputs: List[tf.Tensor]\n ) -\u003e tf.Tensor\n\nPerforms the interaction operation on the tensors in the list.\n\nThe tensors represent as transformed dense features and embedded categorical\nfeatures.\nPre-condition: The tensors should all have the same shape.\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Args ||\n|----------|-----------------------------------------------------------|\n| `inputs` | List of features with shapes \\[batch_size, feature_dim\\]. |\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n\u003cbr /\u003e\n\n| Returns ||\n|---------------|---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| `activations` | Tensor representing interacted features. It has a dimension `num_features * num_features` if skip_gather is True, otherside `num_features * (num_features + 1) / 2` if self_interaction is True and `num_features * (num_features - 1) / 2` if self_interaction is False. |\n\n\u003cbr /\u003e"]]