Model¶
- class pybind11_ke.module.model.Model(*args: Any, **kwargs: Any)[源代码]¶
继承自
pybind11_ke.module.BaseModule,仅仅增加了两个属性:ent_tol和rel_tol。- __weakref__¶
list of weak references to the object (if defined)
- forward() torch.Tensor[源代码]¶
定义每次调用时执行的计算。该方法未实现,子类必须重写该方法,否则抛出
NotImplementedError错误。torch.nn.Module子类必须重写torch.nn.Module.forward()。- 返回:
三元组的得分
- 返回类型:
- get_parameters(mode: str = 'numpy', param_dict: dict[str, Any] | None = None) dict[str, numpy.ndarray] | dict[str, list] | dict[str, torch.Tensor]¶
获得模型权重。
- pi_const: torch.nn.parameter.Parameter¶
常数 pi
- predict() torch.Tensor[源代码]¶
KGE 模型的推理方法。该方法未实现,子类必须重写该方法,否则抛出
NotImplementedError错误。- 返回:
三元组的得分
- 返回类型:
- tri2emb(triples: torch.Tensor, negs: torch.Tensor | None = None, mode: str = 'single') tuple[torch.Tensor, torch.Tensor, torch.Tensor][源代码]¶
返回三元组对应的嵌入向量。
- 参数:
triples (str) – 正确的三元组
negs (torch.Tensor) – 负三元组类别
mode – 模式
- 返回:
头实体、关系和尾实体的嵌入向量
- 返回类型:
- zero_const: torch.nn.parameter.Parameter¶
常数 0