merlin.models.tf.DCNModel

merlin.models.tf.DCNModel(schema: merlin.schema.schema.Schema, depth: int, deep_block: merlin.models.tf.core.base.Block = MLPBlock(   (layers): List(     (0): _Dense(       (dense): Dense(512, activation=relu, use_bias=True)     )     (1): _Dense(       (dense): Dense(256, activation=relu, use_bias=True)     )   ) ), stacked=True, input_block: Optional[merlin.models.tf.core.base.Block] = None, prediction_tasks: Optional[Union[merlin.models.tf.prediction_tasks.base.PredictionTask, List[merlin.models.tf.prediction_tasks.base.PredictionTask], merlin.models.tf.prediction_tasks.base.ParallelPredictionBlock]] = None, **kwargs)merlin.models.tf.models.base.Model[source]

Create a model using the architecture proposed in DCN V2: Improved Deep & Cross Network [1]. See Eq. (1) for full-rank and Eq. (2) for low-rank version.

Example Usage::

dcn = DCNModel(schema, depth=2, deep_block=MLPBlock([256, 64])) dcn.compile(optimizer=”adam”) dcn.fit(train_data, epochs=10)

References

[1]. Wang, Ruoxi, et al. “DCN V2: Improved deep & cross network and

practical lessons for web-scale learning to rank systems.” Proceedings of the Web Conference 2021. 2021. https://arxiv.org/pdf/2008.13535.pdf

Parameters
  • schema (Schema) – The Schema with the input features

  • depth (int, optional) – Number of cross-layers to be stacked, by default 1

  • deep_block (Block, optional) – The Block to use as the deep part of the model (typically a MLPBlock)

  • stacked (bool) – Whether to use the stacked version of the model or the parallel version.

  • input_block (Block, optional) – The Block to use as the input layer. If None, a default InputBlockV2 object is instantiated, that creates the embedding tables for the categorical features based on the schema. The embedding dimensions are inferred from the features cardinality. For a custom representation of input data you can instantiate and provide an InputBlockV2 instance.

  • prediction_tasks (optional) – The prediction tasks to be used, by default this will be inferred from the Schema.

Returns

A SequentialBlock with a number of stacked Cross layers

Return type

SequentialBlock

Raises

ValueError – Number of cross layers (depth) should be positive