hopwise.model.sequential_recommender.gru4reckg¶
Classes¶
It is an extension of GRU4Rec, which concatenates item and its corresponding |
Module Contents¶
- class hopwise.model.sequential_recommender.gru4reckg.GRU4RecKG(config, dataset)[source]¶
Bases:
hopwise.model.abstract_recommender.SequentialRecommender
It is an extension of GRU4Rec, which concatenates item and its corresponding pre-trained knowledge graph embedding feature as the input.
- entity_embedding_matrix¶
- embedding_size¶
- num_layers¶
- dropout¶
- freeze_kg¶
- loss_type¶
- item_embedding¶
- entity_embedding¶
- item_emb_dropout¶
- entity_emb_dropout¶
- item_gru_layers¶
- entity_gru_layers¶
- dense_layer¶
- calculate_loss(interaction)[source]¶
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)[source]¶
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)[source]¶
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