class_docstr: Link prediction network for graphs / knowledge graphs
class_docstr_tok: ["Link","prediction","network","for","graphs","\/","knowledge","graphs"]
code: def ComplEx(heads, relations, tails):
      dim = heads.size(1) // 2
  
      head_re, head_im = heads.view(-1, dim, 2).permute(2, 0, 1)
      tail_re, tail_im = tails.view(-1, dim, 2).permute(2, 0, 1)
      relation_re, relation_im = relations.view(-1, dim, 2).permute(
          2, 0, 1
      )
  
      x_re = head_re * relation_re - head_im * relation_im
      x_im = head_re * relation_im + head_im * relation_re
      x = x_re * tail_re + x_im * tail_im
      score = x.sum(dim=1)
      return score
  
file_path: graphvite/python/graphvite/application/network.py
imports: from __future__ import absolute_import
  import types
  import numpy
  import torch
  from torch import nn
label_desc: Use image node_id 7 for calling the LinkPredictor obj's underlying member method code with example usage: obj.ComplEx(heads, relations, tails) and returns: score