DIN

Reference:

Guorui Zhou et al. “Deep Interest Network for Click-Through Rate Prediction” in ACM SIGKDD 2018

Reference code:
class recbole.model.sequential_recommender.din.DIN(config, dataset)[source]

Bases: recbole.model.abstract_recommender.SequentialRecommender

Deep Interest Network utilizes the attention mechanism to get the weight of each user’s behavior according to the target items, and finally gets the user representation.

Note

In the official source code, unlike the paper, user features and context features are not input into DNN. We just migrated and changed the official source code. But You can get user features embedding from user_feat_list. Besides, in order to compare with other models, we use AUC instead of GAUC to evaluate the model.

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

forward(user, item_seq, item_seq_len, next_items)[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.

input_type = 1
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