class_docstr: AFM is a attention based FM model that predict the final score with the attention of input feature.
class_docstr_tok: ["AFM","is","a","attention","based","FM","model","that","predict","the","final","score","with","the","attention","of","input","feature","."]
code: def __init__(self, config, dataset):
      super(AFM, self).__init__(config, dataset)
  
      # load parameters info
      self.attention_size = config["attention_size"]
      self.dropout_prob = config["dropout_prob"]
      self.reg_weight = config["reg_weight"]
      self.num_pair = (
          self.num_feature_field * (self.num_feature_field - 1) / 2
      )
  
      # define layers and loss
      self.attlayer = AttLayer(self.embedding_size, self.attention_size)
      self.p = nn.Parameter(
          torch.randn(self.embedding_size), requires_grad=True
      )
      self.dropout_layer = nn.Dropout(p=self.dropout_prob)
      self.sigmoid = nn.Sigmoid()
      self.loss = nn.BCEWithLogitsLoss()
  
      # parameters initialization
      self.apply(self._init_weights)
  
file_path: RecBole/recbole/model/context_aware_recommender/afm.py
imports: import torch
  import torch.nn
  from torch.nn.init import xavier_normal_, constant_
  from recbole.model.abstract_recommender import ContextRecommender
  from recbole.model.layers import AttLayer
label_desc: Use image node_id 1 to create a new AFM object from inherited base classes: ContextRecommender with example: obj = AFM(config, dataset)