merlin.models.tf.CrossBlock#
- merlin.models.tf.CrossBlock(depth: int = 1, filter: Optional[Union[merlin.schema.schema.Schema, merlin.schema.tags.Tags, List[str], merlin.models.tf.core.tabular.Filter]] = None, low_rank_dim: Optional[int] = None, use_bias: bool = True, kernel_initializer: Union[str, keras.initializers.initializers.Initializer] = 'truncated_normal', bias_initializer: Union[str, keras.initializers.initializers.Initializer] = 'zeros', kernel_regularizer: Optional[Union[str, keras.regularizers.Regularizer]] = None, bias_regularizer: Optional[Union[str, keras.regularizers.Regularizer]] = None, inputs: Optional[keras.engine.base_layer.Layer] = None, **kwargs) merlin.models.tf.core.combinators.SequentialBlock [source]#
- This block provides a way to create high-order feature interactions
by a number of stacked Cross Layers, from DCN V2: Improved Deep & Cross Network [1]. See Eq. (1) for full-rank and Eq. (2) for low-rank version.
References
- Parameters
depth (int, optional) – Number of cross-layers to be stacked, by default 1
filter (Optional[Union[Schema, Tags, List[str], Filter]], optional) – Features filter to be applied on the input, by default None
low_rank_dim (Optional[int], optional) – If this argument is provided, the weight (W in R(dxd)), where d is the input features dimension matrix, is factorized in a low-rank matrix W = U*V where U and D have (dxr) shape and low_rank_dim = r, by default None
use_bias (bool, optional) – Enables or not the bias term, by default True
kernel_initializer (InitializerType, optional) – Initializer to use on the kernel matrix, by default “truncated_normal”
bias_initializer (InitializerType, optional) – Initializer to use on the bias vector, by default “zeros”
kernel_regularizer (Optional[RegularizerType], optional) – Regularizer to use on the kernel matrix, by default None
bias_regularizer (Optional[RegularizerType], optional) – Regularizer to use on the bias vector, by default None
inputs (Optional[tf.keras.layers.Layer], optional) – If an InputBlock is provided, this block checks if features are being aggregated with concat, otherwise it does that, as cross blocks need features to be aggregated before, by default None
- Returns
A SequentialBlock with a number of stacked Cross layers
- Return type
- Raises
ValueError – Number of cross layers (depth) should be positive