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","."]
docstr: Get the attention-based feature interaction score
  
  Args:
      infeature (torch.FloatTensor): input feature embedding tensor. shape of [batch_size, field_size, embed_dim].
  
  Returns:
      torch.FloatTensor: Result of score. shape of [batch_size, 1].
docstr_tok: ["Get","the","attention-based","feature","interaction","score","Args",":","infeature","(","torch.FloatTensor",")",":","input","feature","embedding","tensor",".","shape","of","[","batch_size",",","field_size",",","embed_dim","]",".","Returns",":","torch.FloatTensor",":","Result","of","score",".","shape","of","[","batch_size",",","1","]","."]
code: def afm_layer(self, infeature):
      """Get the attention-based feature interaction score
  
      Args:
          infeature (torch.FloatTensor): input feature embedding tensor. shape of [batch_size, field_size, embed_dim].
  
      Returns:
          torch.FloatTensor: Result of score. shape of [batch_size, 1].
      """
      p, q = self.build_cross(infeature)
      pair_wise_inter = torch.mul(
          p, q
      )  # [batch_size, num_pairs, emb_dim]
  
      # [batch_size, num_pairs, 1]
      att_signal = self.attlayer(pair_wise_inter).unsqueeze(dim=2)
  
      att_inter = torch.mul(
          att_signal, pair_wise_inter
      )  # [batch_size, num_pairs, emb_dim]
      att_pooling = torch.sum(att_inter, dim=1)  # [batch_size, emb_dim]
      att_pooling = self.dropout_layer(
          att_pooling
      )  # [batch_size, emb_dim]
  
      att_pooling = torch.mul(
          att_pooling, self.p
      )  # [batch_size, emb_dim]
      att_pooling = torch.sum(
          att_pooling, dim=1, keepdim=True
      )  # [batch_size, 1]
  
      return att_pooling
  
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 4 for calling the AFM obj's underlying member method code with example usage: obj.afm_layer(infeature) and returns: att_pooling