固定模型
- class FixedModel(*, triples_factory: KGInfo, **_kwargs)[源代码]
基础类:
Model一个返回固定分数的模拟模型。
\[score(h, r, t) = h \cdot |\mathcal{E}| \cdot |\mathcal{R}| + r \cdot |\mathcal{E}| + t\]初始化模型。
- Parameters:
triples_factory (KGInfo) – (训练)三元组工厂
_kwargs – 忽略基于关键字的参数
属性摘要
优化模型超参数的默认策略
方法总结
获取损失函数的正则化项。
score_h(rt_batch[, heads])使用左侧(头部)预测进行前向传递。
score_hrt(hrt_batch, **kwargs)前向传播。
score_r(ht_batch[, relations])使用中间(关系)预测进行前向传递。
score_t(hr_batch[, tails])使用右侧(尾部)预测进行前向传递。
属性文档
方法文档
- score_h(rt_batch: Tensor, heads: Tensor | None = None, **kwargs) Tensor[source]
使用左侧(头部)预测进行前向传递。
此方法为每个(关系,尾部)对计算所有可能头部的分数。
- Parameters:
- Returns:
形状: (batch_size, num_heads), 数据类型: float 对于每个r-t对,所有可能头部的分数。
- Return type:
- score_r(ht_batch: Tensor, relations: Tensor | None = None, **kwargs) Tensor[source]
使用中间(关系)预测进行前向传递。
此方法为每个(头,尾)对计算所有可能关系的分数。
- Parameters:
- Returns:
形状: (batch_size, num_real_relations), 数据类型: float 对于每个h-t对,所有可能关系的分数。
- Return type: