UniformStrategy
- class KGE.ns_strategy.UniformStrategy[source]
Bases:
KGE.ns_strategy.NegativeSamplerAn implementation of uniform negative sampling
Uniform sampling is the most simple negative sampling strategy, usually is the default setting of knowledge graph embedding models. It sample entities from all entites with uniform distribution, and replaces either head or tail entity.
Methods Summary
__call__(X, negative_ratio, side)perform negative sampling
Methods Documentation
- __call__(X, negative_ratio, side)[source]
perform negative sampling
- Parameters
X (
tf.Tensor) – positive triplets to be corrupt.negative_ratio (
int) – number of negative sample.side (
str) – corrup from which side, can be'h'or't'
- Returns
sampling entities
- Return type
tf.Tensor
- __init__(sample_pool)[source]
Initialize UniformStrategy negative sampler.
- Parameters
sample_pool (
tf.Tensor) – entities pool that used to sample.
- __new__(*args, **kwargs)