merlin.schema.schema.Schema, model_outputs: Optional[Union[Sequence[], Dict[str,]]] = 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[,][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)

  • schema (Schema) – Schema of the input data. This Schema object will be automatically generated using [NVTabular]( 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.


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


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

Return type

Union[ModelOutput, ParallelBlock]