hopwise.model.sequential_recommender.hgn¶
- Reference:
Chen Ma et al. “Hierarchical Gating Networks for Sequential Recommendation.”in SIGKDD 2019
Classes¶
HGN sets feature gating and instance gating to get the important feature and item for predicting the next item |
Module Contents¶
- class hopwise.model.sequential_recommender.hgn.HGN(config, dataset)¶
Bases:
hopwise.model.abstract_recommender.SequentialRecommenderHGN sets feature gating and instance gating to get the important feature and item for predicting the next item
- n_user¶
- device¶
- embedding_size¶
- reg_weight¶
- pool_type¶
- item_embedding¶
- user_embedding¶
- w1¶
- w2¶
- b¶
- w3¶
- w4¶
- item_embedding_for_prediction¶
- sigmoid¶
- loss_type¶
- reg_loss(user_embedding, item_embedding, seq_item_embedding)¶
- _init_weights(module)¶
- feature_gating(seq_item_embedding, user_embedding)¶
Choose the features that will be sent to the next stage(more important feature, more focus)
- instance_gating(user_item, user_embedding)¶
Choose the last click items that will influence the prediction( more important more chance to get attention)
- 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