merlin.models.tf.OutputBlock#

merlin.models.tf.OutputBlock(schema: merlin.schema.schema.Schema, model_outputs: Optional[Union[Sequence[merlin.models.tf.outputs.base.ModelOutput], Dict[str, merlin.models.tf.outputs.base.ModelOutput]]] = None, pre: Optional[keras.engine.base_layer.Layer] = None, post: Optional[keras.engine.base_layer.Layer] = None, task_blocks: Optional[Union[keras.engine.base_layer.Layer, Dict[str, keras.engine.base_layer.Layer]]] = None) Union[merlin.models.tf.outputs.base.ModelOutput, merlin.models.tf.core.combinators.ParallelBlock][source]#

Creates model output(s) based on the columns tagged as target in the schema. It outputs either a ModelOutput (e.g. RegressionOutput, BinaryOutput, CategoricalOutput) if there is a single target, or a ParallelBlock with multiple ModelOutput if there are multiple targets (multi-task learning).

Simple Usage::

outputs = OutputBlock(schema)

Parameters
  • schema (Schema) – Schema of the input data. This Schema object will be automatically generated using [NVTabular](https://nvidia-merlin.github.io/NVTabular/stable/Introduction.html). Next to this, it’s also possible to construct it manually.

  • model_outputs (Optional[Union[Sequence[ModelOutput], Dict[str, ModelOutput]]]) – Optional dict or list of ModelOutput. If a dict, the keys must be the <target_name>/output_type (e.g. “click/binary_output”, “rating/regression_output”)) This method will create ModelOutput only for the tasks not provided in model_outputs.

  • pre (Optional[Layer], optional) – Transformation block to apply before the embeddings lookup, by default None

  • post (Optional[Layer], optional) – Transformation block to apply after the embeddings lookup, by default None

  • task_blocks (Optional[Union[Layer, Dict[str, Layer]]], optional) – Task blocks to be used as task towers. If a single Layer, it is copied to all tasks. If a dict, the keys must match the task names (e.g. “click/binary_output”, rating/regression_output”, “item_id/categorical_output”). You might want to use the task_blocks to create a task-specific tower (e.g. MLPBLock([32])) or to customize inputs, targets or sample_weights for a given task.

Raises

ValueError – when the schema does not contain any target columns.:

Returns

Returns a single output block or a parallel block if there is more than one target column.

Return type

Union[ModelOutput, ParallelBlock]