hopwise.model.knowledge_aware_recommender.mkr

Reference:

Hongwei Wang et al. “Multi-Task Feature Learning for Knowledge Graph Enhanced Recommendation.” in WWW 2019.

Reference code:

https://github.com/hsientzucheng/MKR.PyTorch

Classes

MKR

MKR is a Multi-task feature learning approach for Knowledge graph enhanced Recommendation. It is a deep

CrossCompressUnit

This is Cross&Compress Unit for MKR model to model feature interactions between items and entities.

Module Contents

class hopwise.model.knowledge_aware_recommender.mkr.MKR(config, dataset)[source]

Bases: hopwise.model.abstract_recommender.KnowledgeRecommender

MKR is a Multi-task feature learning approach for Knowledge graph enhanced Recommendation. It is a deep end-to-end framework that utilizes knowledge graph embedding task to assist recommendation task. The two tasks are associated by cross&compress units, which automatically share latent features and learn high-order interactions between items in recommender systems and entities in the knowledge graph.

input_type
LABEL
embedding_size
kg_embedding_size
L
H
reg_weight
use_inner_product
dropout_prob
user_embeddings_lookup
item_embeddings_lookup
entity_embeddings_lookup
relation_embeddings_lookup
user_mlp
tail_mlp
cc_unit
kge_mlp
kge_pred_mlp
sigmoid_BCE
forward(user_indices=None, item_indices=None, head_indices=None, relation_indices=None, tail_indices=None)[source]
_l2_loss(inputs)[source]
calculate_rs_loss(interaction)[source]

Calculate the training loss for a batch data of RS.

calculate_kg_loss(interaction)[source]

Calculate the training loss for a batch data of KG.

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

class hopwise.model.knowledge_aware_recommender.mkr.CrossCompressUnit(dim)[source]

Bases: torch.nn.Module

This is Cross&Compress Unit for MKR model to model feature interactions between items and entities.

dim
fc_vv
fc_ev
fc_ve
fc_ee
forward(inputs)[source]