class_docstr: FwFM is a context-based recommendation model. It aims to model the different feature interactions
  between different fields in a much more memory-efficient way. It proposes a field pair weight matrix
  :math:`r_{F(i),F(j)}`, to capture the heterogeneity of field pair interactions.
  
  The model defines as follows:
  
  .. math::
     y = w_0 + \sum_{i=1}^{m}x_{i}w_{i} + \sum_{i=1}^{m}\sum_{j=i+1}^{m}x_{i}x_{j}<v_{i}, v_{j}>r_{F(i),F(j)}
class_docstr_tok: ["FwFM","is","a","context-based","recommendation","model",".","It","aims","to","model","the","different","feature","interactions","between","different","fields","in","a","much","more","memory-efficient","way",".","It","proposes","a","field","pair","weight","matrix",":","math",":","`","r_","{","F","(","i",")",",","F","(","j",")","}","`",",","to","capture","the","heterogeneity","of","field","pair","interactions",".","The","model","defines","as","follows",":","..","math",":",":","y","=","w_0","+","\\sum_","{","i=1","}","^","{","m","}","x_","{","i","}","w_","{","i","}","+","\\sum_","{","i=1","}","^","{","m","}","\\sum_","{","j=i+1","}","^","{","m","}","x_","{","i","}","x_","{","j","}","<","v_","{","i","}",",","v_","{","j","}",">","r_","{","F","(","i",")",",","F","(","j",")","}"]
code: def __init__(self, config, dataset):
      super(FwFM, self).__init__(config, dataset)
  
      # load parameters info
      self.dropout_prob = config["dropout_prob"]
      self.fields = config[
          "fields"
      ]  # a dict; key: field_id; value: feature_list
  
      self.num_features = self.num_feature_field
  
      self.dropout_layer = nn.Dropout(p=self.dropout_prob)
      self.sigmoid = nn.Sigmoid()
  
      self.feature2id = {}
      self.feature2field = {}
  
      self.feature_names = (
          self.token_field_names,
          self.token_seq_field_names,
          self.float_field_names,
      )
      self.feature_dims = (
          self.token_field_dims,
          self.token_seq_field_dims,
          self.float_field_dims,
      )
      self._get_feature2field()
      self.num_fields = len(
          set(self.feature2field.values())
      )  # the number of fields
      self.num_pair = self.num_fields * self.num_fields
      self.weight = torch.randn(
          self.num_fields,
          self.num_fields,
          1,
          requires_grad=True,
          device=self.device,
      )
      self.loss = nn.BCEWithLogitsLoss()
  
      # parameters initialization
      self.apply(self._init_weights)
  
file_path: RecBole/recbole/model/context_aware_recommender/fwfm.py
imports: import torch
  import torch.nn
  from torch.nn.init import xavier_normal_, constant_
  from recbole.model.abstract_recommender import ContextRecommender
label_desc: Use image node_id 1 to create a new FwFM object from inherited base classes: ContextRecommender with example: obj = FwFM(config, dataset)