# LINE¶

Reference:

Jian Tang et al. “LINE: Large-scale Information Network Embedding.” in WWW 2015.

Reference code:

https://github.com/shenweichen/GraphEmbedding

class recbole.model.general_recommender.line.LINE(config, dataset)[source]

LINE is a graph embedding model.

We implement the model to train users and items embedding for recommendation.

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

context_forward(h, t, field)[source]
forward(h, t)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

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

get_used_ids()[source]
get_user_id_list()[source]
input_type = 2
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

random_num(num)[source]
sampler(key_ids)[source]
training: bool
class recbole.model.general_recommender.line.NegSamplingLoss[source]

Bases: torch.nn.modules.module.Module

forward(score, sign)[source]

Defines the computation performed at every call.

Should be overridden by all subclasses.

Note

Although the recipe for forward pass needs to be defined within this function, one should call the Module instance afterwards instead of this since the former takes care of running the registered hooks while the latter silently ignores them.

training: bool