class_docstr: KSR integrates the RNN-based networks with Key-Value Memory Network (KV-MN).
  And it further incorporates knowledge base (KB) information to enhance the semantic representation of KV-MN.
class_docstr_tok: ["KSR","integrates","the","RNN-based","networks","with","Key-Value","Memory","Network","(","KV-MN",")",".","And","it","further","incorporates","knowledge","base","(","KB",")","information","to","enhance","the","semantic","representation","of","KV-MN","."]
docstr: define read operator
docstr_tok: ["define","read","operator"]
code: def memory_read(self, seq_output, user_memory):
      """define read operator"""
      attrs = self.relation_Matrix
      attentions = nn.functional.softmax(
          self.gamma
          * torch.matmul(seq_output, attrs.transpose(0, 1)).float(),
          -1,
      )  # [B R]
      u_m = torch.mul(user_memory, attentions.unsqueeze(-1)).sum(
          1
      )  # [B K]
      return u_m
  
file_path: RecBole/recbole/model/sequential_recommender/ksr.py
imports: import torch
  from torch import nn
  from torch.nn.init import xavier_uniform_, xavier_normal_
  from recbole.model.abstract_recommender import SequentialRecommender
  from recbole.model.loss import BPRLoss
label_desc: Use image node_id 6 for calling the KSR obj's underlying member method code with example usage: obj.memory_read(seq_output, user_memory) and returns: u_m