typing.Optional[merlin.schema.schema.Schema] = None, categorical: typing.Union[merlin.schema.tags.Tags, keras.engine.base_layer.Layer] = Tags.CATEGORICAL, continuous: typing.Union[merlin.schema.tags.Tags, keras.engine.base_layer.Layer] = Tags.CONTINUOUS, pre: typing.Optional[typing.Union[, str, typing.Sequence[str]]] = None, post: typing.Optional[typing.Union[, str, typing.Sequence[str]]] = None, aggregation: typing.Optional[typing.Union[str,]] = 'concat', tag_to_block={<Tags.CONTINUOUS: 'continuous'>: <class ''>, <Tags.CATEGORICAL: 'categorical'>: <function Embeddings>}, **branches)[source]#

The entry block of the model to process input features from a schema.

This is a new version of InputBlock, which is more flexible for accepting the external definition of embeddings block. After 22.10 this will become the default.

Simple Usage::

inputs = InputBlockV2(schema)

Custom Embeddings::
inputs = InputBlockV2(

schema, categorical=Embeddings(schema, dim=32)


Sparse outputs for one-hot::
inputs = InputBlockV2(

schema, categorical=CategoryEncoding(schema, sparse=True), post=ToSparse()


Add continuous projection::
inputs = InputBlockV2(

schema, continuous=ContinuousProjection(continuous_schema, MLPBlock([32])),


Merge 2D and 3D (for session-based)::
inputs = InputBlockV2(

schema, post=BroadcastToSequence(context_schema, sequence_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.

  • categorical (Union[Tags, Layer], defaults to Tags.CATEGORICAL) – A block or column-selector to use for categorical-features. If a column-selector is provided (either a schema or tags), the selector will be passed to Embeddings to infer the embedding tables from the column-selector.

  • continuous (Union[Tags, Layer], defaults to Tags.CONTINUOUS) – A block to use for continuous-features. If a column-selector is provided (either a schema or tags), the selector will be passed to Continuous to infer the features from the column-selector.

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

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

  • aggregation (Optional[TabularAggregationType], optional) – Transformation block to apply for aggregating the inputs, by default “concat”

  • tag_to_block (Dict[str, Callable[[Schema], Layer]], optional) –

    Mapping from tag to block-type, by default:

    Tags.CONTINUOUS -> Continuous Tags.CATEGORICAL -> Embeddings

  • **branches (dict) – Extra branches to add to the input block.


Returns a ParallelBlock with a Dict with two branches: continuous and embeddings

Return type