class_docstr: SpectralCF is a spectral convolution model that directly learns latent factors of users and items 
  from the spectral domain for recommendation.
  
  The spectral convolution operation with C input channels and F filters is shown as the following:
  
  .. math::
      \left[\begin{array} {c} X_{new}^{u} \\
      X_{new}^{i} \end{array}\right]=\sigma\left(\left(U U^{\top}+U \Lambda U^{\top}\right)
      \left[\begin{array}{c} X^{u} \\
      X^{i} \end{array}\right] \Theta^{\prime}\right)
  
  where :math:`X_{new}^{u} \in R^{n_{users} \times F}` and :math:`X_{new}^{i} \in R^{n_{items} \times F}` 
  denote convolution results learned with F filters from the spectral domain for users and items, respectively; 
  :math:`\sigma` denotes the logistic sigmoid function.
  
  Note:
  
      Our implementation is a improved version which is different from the original paper.
      For a better stability, we replace :math:`U U^T` with identity matrix :math:`I` and
      replace :math:`U \Lambda U^T` with laplace matrix :math:`L`.
class_docstr_tok: ["SpectralCF","is","a","spectral","convolution","model","that","directly","learns","latent","factors","of","users","and","items","from","the","spectral","domain","for","recommendation",".","The","spectral","convolution","operation","with","C","input","channels","and","F","filters","is","shown","as","the","following",":","..","math",":",":","\\left","[","\\begin","{","array","}","{","c","}","X_","{","new","}","^","{","u","}","\\\\","X_","{","new","}","^","{","i","}","\\end","{","array","}","\\right","]","=\\sigma\\left","(","\\left","(","U","U^","{","\\top","}","+U","\\Lambda","U^","{","\\top","}","\\right",")","\\left","[","\\begin","{","array","}","{","c","}","X^","{","u","}","\\\\","X^","{","i","}","\\end","{","array","}","\\right","]","\\Theta^","{","\\prime","}","\\right",")","where",":","math",":","`","X_","{","new","}","^","{","u","}","\\in","R^","{","n_","{","users","}","\\times","F","}","`","and",":","math",":","`","X_","{","new","}","^","{","i","}","\\in","R^","{","n_","{","items","}","\\times","F","}","`","denote","convolution","results","learned","with","F","filters","from","the","spectral","domain","for","users","and","items",",","respectively",";",":","math",":","`","\\sigma","`","denotes","the","logistic","sigmoid","function",".","Note",":","Our","implementation","is","a","improved","version","which","is","different","from","the","original","paper",".","For","a","better","stability",",","we","replace",":","math",":","`","U","U^T","`","with","identity","matrix",":","math",":","`","I","`","and","replace",":","math",":","`","U","\\Lambda","U^T","`","with","laplace","matrix",":","math",":","`","L","`","."]
docstr: Get the laplacian matrix of users and items.
  
  .. math::
      L = I - D^{-1} \times A
  
  Returns:
      Sparse tensor of the laplacian matrix.
docstr_tok: ["Get","the","laplacian","matrix","of","users","and","items",".","..","math",":",":","L","=","I","-","D^","{","-1","}","\\times","A","Returns",":","Sparse","tensor","of","the","laplacian","matrix","."]
code: def get_laplacian_matrix(self):
      r"""Get the laplacian matrix of users and items.
  
      .. math::
          L = I - D^{-1} \times A
  
      Returns:
          Sparse tensor of the laplacian matrix.
      """
      # build adj matrix
      A = sp.dok_matrix(
          (self.n_users + self.n_items, self.n_users + self.n_items),
          dtype=np.float32,
      )
      inter_M = self.interaction_matrix
      inter_M_t = self.interaction_matrix.transpose()
      data_dict = dict(
          zip(
              zip(inter_M.row, inter_M.col + self.n_users),
              [1] * inter_M.nnz,
          )
      )
      data_dict.update(
          dict(
              zip(
                  zip(inter_M_t.row + self.n_users, inter_M_t.col),
                  [1] * inter_M_t.nnz,
              )
          )
      )
      A._update(data_dict)
  
      # norm adj matrix
      sumArr = (A > 0).sum(axis=1)
      diag = np.array(sumArr.flatten())[0] + 1e-7
      diag = np.power(diag, -1)
      D = sp.diags(diag)
      A_tilde = D * A
  
      # covert norm_adj matrix to tensor
      A_tilde = sp.coo_matrix(A_tilde)
      row = A_tilde.row
      col = A_tilde.col
      i = torch.LongTensor([row, col])
      data = torch.FloatTensor(A_tilde.data)
      A_tilde = torch.sparse.FloatTensor(
          i, data, torch.Size(A_tilde.shape)
      )
  
      # generate laplace matrix
      L = self.get_eye_mat(self.n_items + self.n_users) - A_tilde
      return L
  
file_path: RecBole/recbole/model/general_recommender/spectralcf.py
imports: import numpy
  import scipy.sparse
  import torch
  from recbole.model.abstract_recommender import GeneralRecommender
  from recbole.model.init import xavier_uniform_initialization
  from recbole.model.loss import BPRLoss, EmbLoss
  from recbole.utils import InputType
label_desc: Use image node_id 2 for calling the SpectralCF obj's underlying member method code with example usage: obj.get_laplacian_matrix() and returns: L