(heads, relations, tails)
| 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): |
nothing calls this directly
no outgoing calls
no test coverage detected