merlin.models.tf.FMBlock#

merlin.models.tf.FMBlock(schema: merlin.schema.schema.Schema, fm_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, factors_dim: Optional[int] = None, **kwargs) tensorflow.python.framework.ops.Tensor[source]#

Implements the Factorization Machine, as introduced in [1]. It consists in the sum of a wide component that weights each feature individually and a 2nd-level feature interaction using factors.

References

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

Parameters
  • schema (Schema) – The schema of input features

  • fm_input_block (Optional[Block], by default None) – The input block for the 2nd-order feature interaction in Factorization Machine. Only categorical features will be used by this block, as it computes dot product between all paired combinations of embedding values. If not provided, an InputBlockV2 is instantiated based on schema. Note: All features (including continuous) are considered in the 1st-order (wide) part which uses another input block.

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

  • factors_dim (Optional[int], optional) – If fm_input_block is not provided, the factors_dim is used to define the embeddings dim to instantiate InputBlockV2, by default None

Returns

Returns a 2D tensor (batch size, 1) with the sum of the wide component and 2nd-order interaction component of FM

Return type

tf.Tensor