merlin.models.tf.DenseResidualBlock#

merlin.models.tf.DenseResidualBlock(low_rank_dim: Optional[int] = None, activation: Optional[Union[str, keras.engine.base_layer.Layer]] = 'relu', use_bias: bool = True, dropout: Optional[float] = None, normalization: Optional[Union[str, keras.engine.base_layer.Layer]] = 'batch_norm', depth: int = 1, **dense_kwargs) merlin.models.tf.core.base.Block[source]#

A block that applies a dense residual block to the input. The residual consists in the input summed element-wise with the output of the dense block. The dense block projects the inputs using dense layers to the same output dim. If the input dim is very high dimensional, the low_rank_dim can be used to create a low rank matrix and reduce the necessary number of parameters for this projection.

Example usage::

block = ml.DenseResidualBlock(depth=3).connect(ml.MLPBlock([1]))

Parameters
  • low_rank_dim (int, optional) – The dimension of the low rank matrix. If set, it projects the input to the low_rank_dim (LR) and then back to the input dim (I) as output. That requires much less parameters (I*LR + LR*I) than projecting the inputs dim directly to the same dim (I*I). By default None

  • activation (Union[str, tf.keras.layers.Layer], optional) – The activation function to use. By default “relu”

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

  • dropout (float) – The dropout rate to use. By default 0.0

  • normalization (Union[str, tf.keras.layers.Layer], optional) – The normalization layer to use. By the default None.

  • depth (int) – The number of residual blocks to stack. By default 1