Torch Dataloader

Torch Layers

class nvtabular.framework_utils.torch.layers.embeddings.ConcatenatedEmbeddings(embedding_table_shapes, dropout=0.0, sparse_columns=())[source]

Bases: torch.nn.modules.module.Module

Map multiple categorical variables to concatenated embeddings.

Parameters
  • embedding_table_shapes – A dictionary mapping column names to (cardinality, embedding_size) tuples.

  • dropout – A float.

  • sparse_columns – A list of sparse columns

Inputs:

x: An int64 Tensor with shape [batch_size, num_variables].

Outputs:

A Float Tensor with shape [batch_size, embedding_size_after_concat].

forward(x)[source]
training: bool
class nvtabular.framework_utils.torch.layers.embeddings.MultiHotEmbeddings(embedding_table_shapes, dropout=0.0, mode='sum')[source]

Bases: torch.nn.modules.module.Module

Map multiple categorical variables to concatenated embeddings.

Parameters
  • embedding_dict_shapes – A dictionary mapping column names to (cardinality, embedding_size) tuples.

  • dropout – A float.

Inputs:
x: A dictionary with multi-hot column name as keys and a tuple

containing the column values and offsets as values.

Outputs:

A Float Tensor with shape [batch_size, embedding_size_after_concat].

forward(x)[source]
training: bool
class nvtabular.framework_utils.torch.models.Model(embedding_table_shapes, num_continuous, emb_dropout, layer_hidden_dims, layer_dropout_rates, max_output=None, bag_mode='sum')[source]

Bases: torch.nn.modules.module.Module

Generic Base Pytorch Model, that contains support for Categorical and Continuous values.

Parameters
  • embedding_tables_shapes (dict) – A dictionary representing the <column>: <max cardinality of column> for all categorical columns.

  • num_continuous (int) – Number of continuous columns in data.

  • emb_dropout (float, 0 - 1) – Sets the embedding dropout rate.

  • layer_hidden_dims (list) – Hidden layer dimensions.

  • layer_dropout_rates (list) – A list of the layer dropout rates expressed as floats, 0-1, for each layer

  • max_output (float) – Signifies the max output.

forward(x_cat, x_cont)[source]
training: bool