# PseudoTypedNegativeSampler

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

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_size, 3) The positive triples.

Returns

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