MCPcopy Create free account
hub / github.com/DeepGraphLearning/graphvite / ComplEx

Method ComplEx

python/graphvite/application/network.py:105–116  ·  view source on GitHub ↗
(heads, relations, tails)

Source from the content-addressed store, hash-verified

103
104 @staticmethod
105 def ComplEx(heads, relations, tails):
106 dim = heads.size(1) // 2
107
108 head_re, head_im = heads.view(-1, dim, 2).permute(2, 0, 1)
109 tail_re, tail_im = tails.view(-1, dim, 2).permute(2, 0, 1)
110 relation_re, relation_im = relations.view(-1, dim, 2).permute(2, 0, 1)
111
112 x_re = head_re * relation_re - head_im * relation_im
113 x_im = head_re * relation_im + head_im * relation_re
114 x = x_re * tail_re + x_im * tail_im
115 score = x.sum(dim=1)
116 return score
117
118 @staticmethod
119 def SimplE(heads, relations, tails):

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected