class_docstr: RotatE model.
class_docstr_tok: ["RotatE","model","."]
docstr: Construct train program
docstr_tok: ["Construct","train","program"]
code: def construct_train_program(self):
      """
      Construct train program
      """
      zero_var = fluid.layers.fill_constant(
          shape=[1], dtype="float32", value=0.0
      )
      epsilon_var = fluid.layers.fill_constant(
          shape=[1], dtype="float32", value=1e-12
      )
      (
          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_tail, pos_rel, epsilon_var, zero_var
      )
      neg_score = self.score_with_l2_normalize(
          neg_head, neg_tail, neg_rel, epsilon_var, self.train_neg_mode
      )
  
      neg_score = fluid.layers.reshape(
          neg_score, shape=[-1, self._neg_times], inplace=True
      )
  
      if self._adv_temp_value > 0.0:
          sigmoid_pos_score = fluid.layers.logsigmoid(1.0 * pos_score)
          sigmoid_neg_score = fluid.layers.logsigmoid(
              -1.0 * neg_score
          ) * self.adverarial_weight(neg_score)
          sigmoid_neg_score = fluid.layers.reduce_sum(
              sigmoid_neg_score, dim=-1
          )
      else:
          sigmoid_pos_score = fluid.layers.logsigmoid(pos_score)
          sigmoid_neg_score = fluid.layers.logsigmoid(-1.0 * neg_score)
  
      loss_1 = fluid.layers.mean(sigmoid_pos_score)
      loss_2 = fluid.layers.mean(sigmoid_neg_score)
      loss = -1.0 * (loss_1 + loss_2) / 2
      return [loss]
  
file_path: PGL/legacy/examples/pgl-ke/model/RotatE.py
imports: import paddle.fluid
  from .Model import Model
  from .utils import lookup_table
label_desc: Use image node_id 6 for calling the RotatE obj's underlying member method code with example usage: obj.construct_train_program() and returns: list