BasicNegativeSampler

class BasicNegativeSampler(triples_factory, num_negs_per_pos=None)[source]

Bases: pykeen.sampling.negative_sampler.NegativeSampler

A basic negative sampler.

Initialize the negative sampler with the given entities.

Parameters
  • triples_factory (TriplesFactory) – The factory holding the triples to sample from

  • num_negs_per_pos (Optional[int]) – Number of negative samples to make per positive triple. Defaults to 1.

Attributes Summary

hpo_default

The default strategy for optimizing the negative sampler’s hyper-parameters

Methods Summary

sample(positive_batch)

Generate negative samples from the positive batch.

Attributes Documentation

hpo_default: ClassVar[Mapping[str, Mapping[str, Any]]] = {'num_negs_per_pos': {'high': 100, 'low': 1, 'q': 10, 'type': <class 'int'>}}

The default strategy for optimizing the negative sampler’s hyper-parameters

Methods Documentation

sample(positive_batch)[source]

Generate negative samples from the positive batch.

Return type

LongTensor