Eval_Task¶
link_prediction¶
- neuralkg_ind.eval_task.link_prediction.link_predict(batch, model, prediction='all', model_name=None)[source]¶
The evaluate task is predicting the head entity or tail entity in incomplete triples.
- Parameters:
batch – The batch of the triples for validation or test.
model – The KG model for training.
predicion – mode of link prediction.
- Returns:
The rank of the triple to be predicted.
- Return type:
ranks
- neuralkg_ind.eval_task.link_prediction.ind_predict(batch, model)[source]¶
Getting the ranking of positive samples in the other 50 negative samples.
- Parameters:
batch – The batch of sample for test.
model – The inductive model for training.
- Returns:
The rank of the triple to be predicted.
- Return type:
ranks
- neuralkg_ind.eval_task.link_prediction.head_predict(batch, model)[source]¶
Getting head entity ranks.
- Parameters:
batch – The batch of the triples for validation or test
model – The KG model for training.
- Returns:
The rank of the head entity to be predicted, dim [batch_size]
- Return type:
tensor
- neuralkg_ind.eval_task.link_prediction.tail_predict(batch, model)[source]¶
Getting tail entity ranks.
- Parameters:
batch – The batch of the triples for validation or test
model – The KG model for training.
- Returns:
The rank of the tail entity to be predicted, dim [batch_size]
- Return type:
tensor
- neuralkg_ind.eval_task.link_prediction.calc_ranks(idx, label, pred_score)[source]¶
Calculating triples score ranks.
- neuralkg_ind.eval_task.link_prediction.link_predict_SEGNN(batch, kg, model, prediction='all')[source]¶
The evaluate task is predicting the head entity or tail entity in incomplete triples.
- Parameters:
batch – The batch of the triples for validation or test.
model – The KG model for training.
predicion – mode of link prediction.
- Returns:
The rank of the triple to be predicted.
- Return type:
ranks
- neuralkg_ind.eval_task.link_prediction.head_predict_SEGNN(batch, ent_emb, rel_emb, model)[source]¶
Getting head entity ranks.
- Parameters:
batch – The batch of the triples for validation or test
model – The KG model for training.
- Returns:
The rank of the head entity to be predicted, dim [batch_size]
- Return type:
tensor
- neuralkg_ind.eval_task.link_prediction.tail_predict_SEGNN(batch, ent_emb, rel_emb, model)[source]¶
Getting tail entity ranks.
- Parameters:
batch – The batch of the triples for validation or test
model – The KG model for training.
- Returns:
The rank of the tail entity to be predicted, dim [batch_size]
- Return type:
tensor