# Latent representations¶

Classes defining user and item latent representations in factorization models.

class spotlight.factorization.representations.BilinearNet(num_users, num_items, embedding_dim=32, user_embedding_layer=None, item_embedding_layer=None, sparse=False)[source]

Bilinear factorization representation.

Encodes both users and items as an embedding layer; the score for a user-item pair is given by the dot product of the item and user latent vectors.

Parameters: num_users (int) – Number of users in the model. num_items (int) – Number of items in the model. embedding_dim (int, optional) – Dimensionality of the latent representations. user_embedding_layer (an embedding layer, optional) – If supplied, will be used as the user embedding layer of the network. item_embedding_layer (an embedding layer, optional) – If supplied, will be used as the item embedding layer of the network. sparse (boolean, optional) – Use sparse gradients.
forward(user_ids, item_ids)[source]

Compute the forward pass of the representation.

Parameters: user_ids (tensor) – Tensor of user indices. item_ids (tensor) – Tensor of item indices. predictions – Tensor of predictions. tensor