merlin.models.tf.MLPBlock#

merlin.models.tf.MLPBlock(dimensions: List[int], activation: Union[str, List[str]] = 'relu', use_bias: bool = True, kernel_initializer: Union[str, keras.initializers.initializers.Initializer] = 'glorot_uniform', bias_initializer: Union[str, keras.initializers.initializers.Initializer] = 'zeros', kernel_regularizer: Optional[Union[str, keras.regularizers.Regularizer]] = None, bias_regularizer: Optional[Union[str, keras.regularizers.Regularizer]] = None, activity_regularizer: Optional[Union[str, keras.regularizers.Regularizer]] = None, dropout: Optional[float] = None, normalization: Optional[Union[str, keras.engine.base_layer.Layer]] = None, filter: Optional[Union[merlin.schema.schema.Schema, merlin.schema.tags.Tags, List[str], merlin.models.tf.core.tabular.Filter]] = None, no_activation_last_layer: bool = False, block_name: str = 'MLPBlock', **kwargs) merlin.models.tf.core.combinators.SequentialBlock[source]#

A block that applies a multi-layer perceptron to the input.

Example usage::

mlp = ml.InputBlock(schema).connect(ml.MLPBlock([64, 32]))

Parameters
  • dimensions (List[int]) – The number of units in each layer of the MLP.

  • activation (str) – The activation function to use.

  • use_bias (bool) – Whether to use a bias in the MLP.

  • kernel_initializer (InitializerType) – Initializer for the kernel weights matrix. Defaults to “glorot_uniform”.

  • bias_initializer (InitializerType) – Initializer for the bias vector. Default to “zeros”.

  • kernel_regularizer (Optional[RegularizerType]) – Regularizer function applied to the kernel weights matrix. Default to None.

  • bias_regularizer (Optional[RegularizerType]) – Regularizer function applied to the bias vector. Default to None.

  • activity_regularizer (Optional[RegularizerType]) – Regularizer function applied to the output of the layer (its “activation”). Default to None.

  • dropout (float) – The dropout rate to use.

  • normalization (str or Layer) – The normalization layer to use.

  • filter (Schema, Tag, List[str], or Filter) – The filter to apply to the inputs of the MLP.

  • no_activation_last_layer (bool) – Ensures that no activation function (i.e. ‘linear’) or droptout is used in the output of the last MLP layer

  • block_name (str) – The name of the block.