伪类型负采样器

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

基础类:NegativeSampler

一个采样器,用于考虑哪些实体与关系共同出现。

为了为三元组 \((h, r, t)\) 生成一个损坏的头实体,只考虑那些在与关系 \(r\) 的三元组中作为头实体出现的实体。

警告

对于这种类型的采样器,过滤假阴性更为重要。

实例化伪类型负采样器。

Parameters:

方法总结

corrupt_batch(positive_batch)

从正样本批次中生成负样本,不应用任何过滤器。

方法文档

corrupt_batch(positive_batch: Tensor)[来源]

从正样本批次中生成负样本,不应用任何过滤器。

Parameters:

positive_batch (Tensor) – 形状: (*batch_dims, 3) 正样本三元组。

Returns:

形状:(*batch_dims, num_negs_per_pos, 3) 负三元组。result[*bi, :, :] 包含从 positive_batch[*bi, :] 生成的负样本。