merlin.models.tf.DeepFMModel#

merlin.models.tf.DeepFMModel(schema: merlin.schema.schema.Schema, embedding_dim: Optional[int] = None, deep_block: Optional[merlin.models.tf.core.base.Block] = None, input_block: Optional[merlin.models.tf.core.base.Block] = None, wide_input_block: Optional[merlin.models.tf.core.base.Block] = None, wide_logit_block: Optional[merlin.models.tf.core.base.Block] = None, deep_logit_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, ModelOutput, merlin.models.tf.core.combinators.ParallelBlock]] = None, **kwargs) merlin.models.tf.models.base.Model[source]#

DeepFM-model architecture, which is the sum of the 1-dim output of a Factorization Machine [2] and a Deep Neural Network

Example Usage::

deep_fm = DeepFMModel(schema, embedding_dim=64, deep_block=MLPBlock([256, 64])) deep_fm.compile(optimizer=”adam”) deep_fm.fit(train_data, epochs=10)

References

[1] Huifeng, Guo, et al.

“DeepFM: A Factorization-Machine based Neural Network for CTR Prediction” arXiv:1703.04247 (2017).

[2] Steffen, Rendle, “Factorization Machines” IEEE International Conference on Data Mining, 2010. https://ieeexplore.ieee.org/document/5694074

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

  • embedding_dim (int) – Dimension of the embeddings

  • deep_block (Optional[Block]) – The Block that learns high-order feature interactions. On top of this Block, an MLPBlock([1]) is added to output a 1-dim logit. Defaults to MLPBlock([64])

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

  • wide_input_block (Optional[Block], by default None) – The input for the wide block. If not provided, creates a default block that encodes categorical features with one-hot / multi-hot representation and also includes the continuous features.

  • wide_logit_block (Optional[Block], by default None) – The output layer of the wide input. The last dimension needs to be 1. You might want to provide your own output logit block if you want to add dropout or kernel regularization to the wide block.

  • deep_logit_block (Optional[Block], by default MLPBlock([1], activation="linear", use_bias=True)) – The output layer of the deep block. The last dimension needs to be 1. You might want to provide your own output logit block if you want to add dropout or kernel regularization to the wide block.

  • 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).

Return type

Model