hopwise.model.sequential_recommender.npe¶
- Reference:
ThaiBinh Nguyen, et al. “NPE: Neural Personalized Embedding for Collaborative Filtering” in IJCAI 2018.
- Reference code:
Classes¶
models a user’s click to an item in two terms: the personal preference of the user for the item, |
Module Contents¶
- class hopwise.model.sequential_recommender.npe.NPE(config, dataset)¶
Bases:
hopwise.model.abstract_recommender.SequentialRecommendermodels a user’s click to an item in two terms: the personal preference of the user for the item, and the relationships between this item and other items clicked by the user
- n_user¶
- device¶
- embedding_size¶
- dropout_prob¶
- user_embedding¶
- item_embedding¶
- embedding_seq_item¶
- relu¶
- dropout¶
- loss_type¶
- _init_weights(module)¶
- forward(seq_item, user)¶
- calculate_loss(interaction)¶
Calculate the training loss for a batch data.
- Parameters:
interaction (Interaction) – Interaction class of the batch.
- Returns:
Training loss, shape: []
- Return type:
torch.Tensor
- predict(interaction)¶
Predict the scores between users and items.
- Parameters:
interaction (Interaction) – Interaction class of the batch.
- Returns:
Predicted scores for given users and items, shape: [batch_size]
- Return type:
torch.Tensor
- full_sort_predict(interaction)¶
Full sort prediction function. Given users, calculate the scores between users and all candidate items.
- Parameters:
interaction (Interaction) – Interaction class of the batch.
- Returns:
Predicted scores for given users and all candidate items, shape: [n_batch_users * n_candidate_items]
- Return type:
torch.Tensor