class_docstr: CFKG is a knowledge-based recommendation model, it combines knowledge graph and the user-item interaction
  graph to a new graph. In this graph, user, item and related attribute are viewed as entities, and the interaction
  between user and item and the link between item and attribute are viewed as relations. It define a new score
  function as follows:
  
  .. math::
      d (u_i + r_{buy}, v_j)
  
  Note:
      In the original paper, CFKG puts recommender data (u-i interaction) and knowledge data (h-r-t) together
      for sampling and mix them for training. In this version, we sample recommender data
      and knowledge data separately, and put them together for training.
class_docstr_tok: ["CFKG","is","a","knowledge-based","recommendation","model",",","it","combines","knowledge","graph","and","the","user-item","interaction","graph","to","a","new","graph",".","In","this","graph",",","user",",","item","and","related","attribute","are","viewed","as","entities",",","and","the","interaction","between","user","and","item","and","the","link","between","item","and","attribute","are","viewed","as","relations",".","It","define","a","new","score","function","as","follows",":","..","math",":",":","d","(","u_i","+","r_","{","buy","}",",","v_j",")","Note",":","In","the","original","paper",",","CFKG","puts","recommender","data","(","u-i","interaction",")","and","knowledge","data","(","h-r-t",")","together","for","sampling","and","mix","them","for","training",".","In","this","version",",","we","sample","recommender","data","and","knowledge","data","separately",",","and","put","them","together","for","training","."]
code: def __init__(self, config, dataset):
      super(CFKG, self).__init__(config, dataset)
  
      # load parameters info
      self.embedding_size = config["embedding_size"]
      self.loss_function = config["loss_function"]
      self.margin = config["margin"]
      assert self.loss_function in ["inner_product", "transe"]
  
      # define layers and loss
      self.user_embedding = nn.Embedding(
          self.n_users, self.embedding_size
      )
      self.entity_embedding = nn.Embedding(
          self.n_entities, self.embedding_size
      )
      self.relation_embedding = nn.Embedding(
          self.n_relations + 1, self.embedding_size
      )
      if self.loss_function == "transe":
          self.rec_loss = nn.TripletMarginLoss(
              margin=self.margin, p=2, reduction="mean"
          )
      else:
          self.rec_loss = InnerProductLoss()
  
      # parameters initialization
      self.apply(xavier_normal_initialization)
  
file_path: RecBole/recbole/model/knowledge_aware_recommender/cfkg.py
imports: import torch
  import torch.nn
  import torch.nn.functional
  from recbole.model.abstract_recommender import KnowledgeRecommender
  from recbole.model.init import xavier_normal_initialization
  from recbole.utils import InputType
label_desc: Use image node_id 1 to create a new CFKG object from inherited base classes: KnowledgeRecommender with example: obj = CFKG(config, dataset)