merlin.schema.schema.Schema, depth: int, deep_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: typing.Optional[] = None, prediction_tasks: typing.Optional[typing.Union[, typing.List[],, ModelOutput,]] = None, **kwargs)[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”), epochs=10)


[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.

  • 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[Union[PredictionTask,List[PredictionTask],) – ParallelPredictionBlock,ModelOutputType] The prediction tasks to be used, by default this will be inferred from the Schema. For custom prediction tasks we recommending using OutputBlock and blocks based on ModelOutput than the ones based in PredictionTask (that will be deprecated).


A SequentialBlock with a number of stacked Cross layers

Return type



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