Negative Sampling

Negative sampling.

Name

Reference

basic

pykeen.sampling.BasicNegativeSampler

bernoulli

pykeen.sampling.BernoulliNegativeSampler

Note

This table can be re-generated with pykeen ls samplers -f rst

Functions

get_negative_sampler_cls(query)

Get the negative sampler class.

Classes

BasicNegativeSampler(triples_factory[, …])

A basic negative sampler.

BernoulliNegativeSampler(triples_factory[, …])

An implementation of the bernoulli negative sampling approach proposed by [wang2014].

Class Inheritance Diagram

Inheritance diagram of pykeen.sampling.basic_negative_sampler.BasicNegativeSampler, pykeen.sampling.bernoulli_negative_sampler.BernoulliNegativeSampler

Base Classes

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

A 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.

hpo_default: ClassVar[Mapping[str, Mapping[str, Any]]]

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

abstract sample(positive_batch)[source]

Generate negative samples from the positive batch.

Return type

LongTensor