PythonSetFilterer

class PythonSetFilterer(mapped_triples)[source]

Bases: Filterer

A filterer using Python sets for filtering.

This filterer is expected to be rather slow due to the conversion from torch long tensors to Python tuples. It can still serve as a baseline for performance comparison.

Initialize the filterer.

Parameters:

mapped_triples (LongTensor) – The ID-based triples.

Methods Summary

contains(batch)

Check whether a triple is contained.

Methods Documentation

contains(batch)[source]

Check whether a triple is contained.

Supports batching.

Parameters:

batch (LongTensor) – shape (batch_size, 3) The batch of triples.

Return type:

BoolTensor

Returns:

shape: (batch_size,) Whether the triples are contained in the training triples.