class_docstr: The TransE Model.
docstr: Construct train program.
docstr_tok: ["Construct","train","program","."]
code: def construct_train_program(self):
      """
      Construct train program.
      """
      (
          entity_embedding,
          relation_embedding,
      ) = self.creat_share_variables()
      pos_head = lookup_table(
          self.train_pos_input[:, 0], entity_embedding
      )
      pos_tail = lookup_table(
          self.train_pos_input[:, 2], entity_embedding
      )
      pos_rel = lookup_table(
          self.train_pos_input[:, 1], relation_embedding
      )
      neg_head = lookup_table(
          self.train_neg_input[:, 0], entity_embedding
      )
      neg_tail = lookup_table(
          self.train_neg_input[:, 2], entity_embedding
      )
      neg_rel = lookup_table(
          self.train_neg_input[:, 1], relation_embedding
      )
  
      pos_score = self.score_with_l2_normalize(
          pos_head, pos_rel, pos_tail
      )
      neg_score = self.score_with_l2_normalize(
          neg_head, neg_rel, neg_tail
      )
  
      pos = fluid.layers.reduce_sum(
          fluid.layers.abs(pos_score), 1, keep_dim=False
      )
      neg = fluid.layers.reduce_sum(
          fluid.layers.abs(neg_score), 1, keep_dim=False
      )
      neg = fluid.layers.reshape(
          neg, shape=[-1, self._neg_times], inplace=True
      )
  
      loss = fluid.layers.reduce_mean(
          fluid.layers.relu(pos - neg + self._margin)
      )
      return [loss]
  
file_path: PGL/legacy/examples/pgl-ke/model/TransE.py
imports: import paddle.fluid
  from .Model import Model
  from .utils import lookup_table
label_desc: Use image node_id 4 for calling the TransE obj's underlying member method code with example usage: obj.construct_train_program() and returns: list