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","`","."]
code: def __init__(self, config, dataset):
      super(SpectralCF, self).__init__(config, dataset)
  
      # load parameters info
      self.n_layers = config["n_layers"]
      self.emb_dim = config["embedding_size"]
      self.reg_weight = config["reg_weight"]
  
      # generate intermediate data
      # "A_hat = I + L" is equivalent to "A_hat = U U^T + U \Lambda U^T"
      self.interaction_matrix = dataset.inter_matrix(form="coo").astype(
          np.float32
      )
      I = self.get_eye_mat(self.n_items + self.n_users)
      L = self.get_laplacian_matrix()
      A_hat = I + L
      self.A_hat = A_hat.to(self.device)
  
      # define layers and loss
      self.user_embedding = torch.nn.Embedding(
          num_embeddings=self.n_users, embedding_dim=self.emb_dim
      )
      self.item_embedding = torch.nn.Embedding(
          num_embeddings=self.n_items, embedding_dim=self.emb_dim
      )
      self.filters = torch.nn.ParameterList(
          [
              torch.nn.Parameter(
                  torch.normal(
                      mean=0.01,
                      std=0.02,
                      size=(self.emb_dim, self.emb_dim),
                  ),
                  requires_grad=True,
              )
              for _ in range(self.n_layers)
          ]
      )
  
      self.sigmoid = torch.nn.Sigmoid()
      self.mf_loss = BPRLoss()
      self.reg_loss = EmbLoss()
      self.restore_user_e = None
      self.restore_item_e = None
  
      self.other_parameter_name = ["restore_user_e", "restore_item_e"]
      # parameters initialization
      self.apply(xavier_uniform_initialization)
  
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 1 to create a new SpectralCF object from inherited base classes: GeneralRecommender with example: obj = SpectralCF(config, dataset)