Cross Layer in Deep & Cross Network to learn explicit feature interactions.
View aliases
Main aliases
tfrs.layers.dcn.Cross(
projection_dim: Optional[int] = None,
diag_scale: Optional[float] = 0.0,
use_bias: bool = True,
preactivation: Optional[Union[str, tf.keras.layers.Activation]] = None,
kernel_initializer: Union[Text, tf.keras.initializers.Initializer] = 'truncated_normal',
bias_initializer: Union[Text, tf.keras.initializers.Initializer] = 'zeros',
kernel_regularizer: Union[Text, None, tf.keras.regularizers.Regularizer] = None,
bias_regularizer: Union[Text, None, tf.keras.regularizers.Regularizer] = None,
**kwargs
)
Used in the notebooks
Used in the tutorials |
---|
A layer that creates explicit and bounded-degree feature interactions
efficiently. The call
method accepts inputs
as a tuple of size 2
tensors. The first input x0
is the base layer that contains the original
features (usually the embedding layer); the second input xi
is the output
of the previous Cross
layer in the stack, i.e., the i-th Cross
layer. For the first Cross
layer in the stack, x0 = xi.
The output is x_{i+1} = x0 .* (W * xi + bias + diag_scale * xi) + xi, where .* designates elementwise multiplication, W could be a full-rank matrix, or a low-rank matrix U*V to reduce the computational cost, and diag_scale increases the diagonal of W to improve training stability ( especially for the low-rank case).
References | |
---|---|
|
Example | |
---|---|
|
Input shape: A tuple of 2 (batch_size, input_dim
) dimensional inputs.
Output shape: A single (batch_size, input_dim
) dimensional output.
Methods
call
call(
x0: tf.Tensor, x: Optional[tf.Tensor] = None
) -> tf.Tensor
Computes the feature cross.
Args | |
---|---|
x0
|
The input tensor |
x
|
Optional second input tensor. If provided, the layer will compute crosses between x0 and x; if not provided, the layer will compute crosses between x0 and itself. |
Returns | |
---|---|
Tensor of crosses. |