hopwise.model.general_recommender.line¶
- Reference:
Jian Tang et al. “LINE: Large-scale Information Network Embedding.” in WWW 2015.
- Reference code:
Classes¶
LINE is a graph embedding model. |
Module Contents¶
- class hopwise.model.general_recommender.line.NegSamplingLoss¶
Bases:
torch.nn.Module- forward(sign, score)¶
- class hopwise.model.general_recommender.line.LINE(config, dataset)¶
Bases:
hopwise.model.abstract_recommender.GeneralRecommenderLINE is a graph embedding model.
We implement the model to train users and items embedding for recommendation.
- input_type¶
- embedding_size¶
- order¶
- second_order_loss_weight¶
- interaction_feat¶
- user_embedding¶
- item_embedding¶
- loss_fct¶
- used_ids¶
- random_list¶
- random_pr = 0¶
- random_list_length¶
- sampler(key_ids)¶
- random_num(num)¶
- get_user_id_list()¶
- forward(h, t)¶
- context_forward(h, t, field)¶
- 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