PseudoTypedNegativeSampler

class PseudoTypedNegativeSampler(*, mapped_triples, **kwargs)[source]

Bases: NegativeSampler

A sampler that accounts for which entities co-occur with a relation.

To generate a corrupted head entity for triple \((h, r, t)\), only those entities are considered which occur as a head entity in a triple with the relation \(r\).

Warning

With this type of sampler, filtering for false negatives is more important.

Instantiate the pseudo-typed negative sampler.

Parameters:

Methods Summary

corrupt_batch(positive_batch)

Generate negative samples from the positive batch without application of any filter.

Methods Documentation

corrupt_batch(positive_batch)[source]

Generate negative samples from the positive batch without application of any filter.

Parameters:

positive_batch (LongTensor) – shape: (*batch_dims, 3) The positive triples.

Returns:

shape: (*batch_dims, num_negs_per_pos, 3) The negative triples. result[*bi, :, :] contains the negative examples generated from positive_batch[*bi, :].