CompGCNTestSampler¶
- class pybind11_ke.data.CompGCNTestSampler(sampler: CompGCNSampler, valid_file: str = 'valid2id.txt', test_file: str = 'test2id.txt', type_constrain: bool = True)[源代码]¶
CompGCN[VSNT20] 的测试数据采样器。例子:
from pybind11_ke.data import RGCNTestSampler, CompGCNTestSampler from torch.utils.data import DataLoader #: 测试数据采样器 test_sampler: typing.Union[typing.Type[RGCNTestSampler], typing.Type[CompGCNTestSampler]] = test_sampler( sampler=train_sampler, valid_file=valid_file, test_file=test_file, ) #: 验证集三元组 data_val: list[tuple[int, int, int]] = test_sampler.get_valid() #: 测试集三元组 data_test: list[tuple[int, int, int]] = test_sampler.get_test() val_dataloader = DataLoader( data_val, shuffle=False, batch_size=test_batch_size, num_workers=num_workers, pin_memory=True, collate_fn=test_sampler.sampling, ) test_dataloader = DataLoader( data_test, shuffle=False, batch_size=test_batch_size, num_workers=num_workers, pin_memory=True, collate_fn=test_sampler.sampling, )
- __init__(sampler: CompGCNSampler, valid_file: str = 'valid2id.txt', test_file: str = 'test2id.txt', type_constrain: bool = True)[源代码]¶
创建 CompGCNTestSampler 对象。
- 参数:
sampler (CompGCNSampler) – 训练数据采样器。
valid_file (str) – valid2id.txt
test_file (str) – test2id.txt
type_constrain (bool) – 是否报告 type_constrain.txt 限制的测试结果
- __weakref__¶
list of weak references to the object (if defined)
- add_valid_test_reverse_triples()¶
对于每一个三元组 (h, r, t),生成相反关系三元组 (t, r`, h): r` = r + rel_tol。
- get_type_constrain_id()¶
读取 type_constrain.txt 文件。
- get_valid_test_triples_id()¶
读取
valid_file文件和test_file文件。
- sampler: Union[TradSampler, RGCNSampler, CompGCNSampler]¶
训练数据采样器