Beispiel #1
0
 def _get_triple_embeddings(self, triples):
     heads, relations, tails = slice_triples(triples)
     return (
         self._get_entity_embeddings(heads),
         self._get_relation_embeddings(relations),
         self._get_entity_embeddings(tails),
     )
Beispiel #2
0
    def _score_triples(self, triples):
        heads, relations, tails = slice_triples(triples)

        h_embs = self._get_entity_embeddings(heads)
        r_embs = self._get_relation_embeddings(relations)
        t_embs = self._get_entity_embeddings(tails)

        h_proj_vec_embs = self._get_entity_projections(heads)
        r_projs_embs = self._get_relation_projections(relations)
        t_proj_vec_embs = self._get_entity_projections(tails)

        proj_heads = self._project_entities(h_embs, h_proj_vec_embs, r_projs_embs)
        proj_tails = self._project_entities(t_embs, t_proj_vec_embs, r_projs_embs)

        scores = self._compute_scores(h_embs=proj_heads, r_embs=r_embs, t_embs=proj_tails)
        return scores