SumOfEmbeddingsConstructor

class rectools.models.nn.item_net.SumOfEmbeddingsConstructor(n_items: int, item_net_blocks: Sequence[ItemNetBase], **kwargs: Any)[source]

Bases: ItemNetConstructorBase

Item net blocks constructor that simply sums all of the its net blocks embeddings.

Parameters
  • n_items (int) – Number of items in the dataset.

  • item_net_blocks (Sequence(ItemNetBase)) – Latent embedding size of item embeddings.

  • kwargs (Any) –

Methods

forward(items)

Forward pass through item net blocks and aggregation of the results.

Attributes

out_dim

Return item net constructor output dimension.

forward(items: Tensor) Tensor[source]

Forward pass through item net blocks and aggregation of the results. Simple sum of embeddings.

Parameters

items (torch.Tensor) – Internal item ids.

Returns

Item embeddings.

Return type

torch.Tensor

property out_dim: int

Return item net constructor output dimension.