class_docstr: DMF is an neural network enhanced matrix factorization model.
  The original interaction matrix of :math:`n_{users} \times n_{items}` is set as model input,
  we carefully design the data interface and use sparse tensor to train and test efficiently.
  We just implement the model following the original author with a pointwise training mode.
  
  Note:
  
      Our implementation is a improved version which is different from the original paper.
      For a better performance and stability, we replace cosine similarity to inner-product when calculate
      final score of user's and item's embedding.
class_docstr_tok: ["DMF","is","an","neural","network","enhanced","matrix","factorization","model",".","The","original","interaction","matrix","of",":","math",":","`","n_","{","users","}","\\times","n_","{","items","}","`","is","set","as","model","input",",","we","carefully","design","the","data","interface","and","use","sparse","tensor","to","train","and","test","efficiently",".","We","just","implement","the","model","following","the","original","author","with","a","pointwise","training","mode",".","Note",":","Our","implementation","is","a","improved","version","which","is","different","from","the","original","paper",".","For","a","better","performance","and","stability",",","we","replace","cosine","similarity","to","inner-product","when","calculate","final","score","of","user","'s","and","item","'s","embedding","."]
code: def __init__(self, config, dataset):
      super(DMF, self).__init__(config, dataset)
  
      # load dataset info
      self.LABEL = config["LABEL_FIELD"]
      self.RATING = config["RATING_FIELD"]
  
      # load parameters info
      self.user_embedding_size = config["user_embedding_size"]
      self.item_embedding_size = config["item_embedding_size"]
      self.user_hidden_size_list = config["user_hidden_size_list"]
      self.item_hidden_size_list = config["item_hidden_size_list"]
      # The dimensions of the last layer of users and items must be the same
      assert (
          self.user_hidden_size_list[-1]
          == self.item_hidden_size_list[-1]
      )
      self.inter_matrix_type = config["inter_matrix_type"]
  
      # generate intermediate data
      if self.inter_matrix_type == "01":
          (
              self.history_user_id,
              self.history_user_value,
              _,
          ) = dataset.history_user_matrix()
          (
              self.history_item_id,
              self.history_item_value,
              _,
          ) = dataset.history_item_matrix()
          self.interaction_matrix = dataset.inter_matrix(
              form="csr"
          ).astype(np.float32)
      elif self.inter_matrix_type == "rating":
          (
              self.history_user_id,
              self.history_user_value,
              _,
          ) = dataset.history_user_matrix(value_field=self.RATING)
          (
              self.history_item_id,
              self.history_item_value,
              _,
          ) = dataset.history_item_matrix(value_field=self.RATING)
          self.interaction_matrix = dataset.inter_matrix(
              form="csr", value_field=self.RATING
          ).astype(np.float32)
      else:
          raise ValueError(
              "The inter_matrix_type must in ['01', 'rating'] but get {}".format(
                  self.inter_matrix_type
              )
          )
      self.max_rating = self.history_user_value.max()
      # tensor of shape [n_items, H] where H is max length of history interaction.
      self.history_user_id = self.history_user_id.to(self.device)
      self.history_user_value = self.history_user_value.to(self.device)
      self.history_item_id = self.history_item_id.to(self.device)
      self.history_item_value = self.history_item_value.to(self.device)
  
      # define layers
      self.user_linear = nn.Linear(
          in_features=self.n_items,
          out_features=self.user_embedding_size,
          bias=False,
      )
      self.item_linear = nn.Linear(
          in_features=self.n_users,
          out_features=self.item_embedding_size,
          bias=False,
      )
      self.user_fc_layers = MLPLayers(
          [self.user_embedding_size] + self.user_hidden_size_list
      )
      self.item_fc_layers = MLPLayers(
          [self.item_embedding_size] + self.item_hidden_size_list
      )
      self.sigmoid = nn.Sigmoid()
      self.bce_loss = nn.BCEWithLogitsLoss()
  
      # Save the item embedding before dot product layer to speed up evaluation
      self.i_embedding = None
  
      # parameters initialization
      self.apply(self._init_weights)
      self.other_parameter_name = ["i_embedding"]
  
file_path: RecBole/recbole/model/general_recommender/dmf.py
imports: import numpy
  import torch
  import torch.nn
  from torch.nn.init import normal_
  from recbole.model.abstract_recommender import GeneralRecommender
  from recbole.model.layers import MLPLayers
  from recbole.utils import InputType
label_desc: Use image node_id 1 to create a new DMF object from inherited base classes: GeneralRecommender with example: obj = DMF(config, dataset)