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, embedding_options: merlin.models.tf.inputs.embedding.EmbeddingOptions = EmbeddingOptions(embedding_dims=None, embedding_dim_default=64, infer_embedding_sizes=False, infer_embedding_sizes_multiplier=2.0, infer_embeddings_ensure_dim_multiple_of_8=False, embeddings_initializers=None, embeddings_l2_reg=0.0, combiner='mean'), 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, by default None

  • embedding_options (EmbeddingOptions) – Options for the input embeddings. - embedding_dims: Optional[Dict[str, int]] - The dimension of the embedding table for each feature (key), by default {} - embedding_dim_default: int - Default dimension of the embedding table, when the feature is not found in embedding_dims, by default 64 - infer_embedding_sizes : bool, Automatically defines the embedding dimension from the feature cardinality in the schema, by default False - infer_embedding_sizes_multiplier: int. Multiplier used by the heuristic to infer the embedding dimension from its cardinality. Generally reasonable values range between 2.0 and 10.0. By default 2.0.

  • 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