From 06a2c5d356222f0844783f655e6a26ae00930d87 Mon Sep 17 00:00:00 2001 From: yukew1998 Date: Thu, 19 Dec 2024 17:17:05 -0500 Subject: [PATCH] update formatting --- CHANGELOG.md | 2 +- torch_geometric/nn/kge/transf.py | 17 +++++++++++------ 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4ac770c9710f..eb4ef3f8326a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -23,7 +23,7 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/). - Added the `use_pcst` option to `WebQSPDataset` ([#9722](https://github.com/pyg-team/pytorch_geometric/pull/9722)) - Allowed users to pass `edge_weight` to `GraphUNet` models ([#9737](https://github.com/pyg-team/pytorch_geometric/pull/9737)) - Consolidated `examples/ogbn_{papers_100m,products_gat,products_sage}.py` into `examples/ogbn_train.py` ([#9467](https://github.com/pyg-team/pytorch_geometric/pull/9467)) -- Added the `TransF` KGE model ([#9858](https://github.com/pyg-team/pytorch_geometric/pull/9858)) +- Added the `TransF` KGE model ([#9880](https://github.com/pyg-team/pytorch_geometric/pull/9880)) ### Changed diff --git a/torch_geometric/nn/kge/transf.py b/torch_geometric/nn/kge/transf.py index 7daf67814c67..31240f56a372 100644 --- a/torch_geometric/nn/kge/transf.py +++ b/torch_geometric/nn/kge/transf.py @@ -7,24 +7,29 @@ from torch_geometric.nn.kge import KGEModel class TransF(KGEModel): - r"""The TransF model from the "Knowledge Graph Embedding by Flexible Translation" - paper. + r""" + The TransF model from the "Knowledge Graph Embedding by Flexible + Translation" paper. :class:`TransF` introduces a flexible translation mechanism by dynamically - scaling the relation vector based on head and tail entity embeddings, resulting in: + scaling the relation vector based on head and tail entity embeddings, + resulting in: .. math:: - \mathbf{e}_h + f(\mathbf{e}_h, \mathbf{e}_t, \mathbf{e}_r) \cdot \mathbf{e}_r \approx \mathbf{e}_t + \mathbf{e}_h + f(\mathbf{e}_h, \mathbf{e}_t, \mathbf{e}_r) + \cdot \mathbf{e}_r \approx \mathbf{e}_t where :math:`f` is a dynamic scaling function: .. math:: - f(\mathbf{e}_h, \mathbf{e}_t, \mathbf{e}_r) = \sigma((\mathbf{e}_h \odot \mathbf{e}_t) \cdot \mathbf{e}_r) + f(\mathbf{e}_h, \mathbf{e}_t, \mathbf{e}_r) = + \sigma((\mathbf{e}_h \odot \mathbf{e}_t) \cdot \mathbf{e}_r) This results in the scoring function: .. math:: - d(h, r, t) = - \| \mathbf{e}_h + f(\mathbf{e}_h, \mathbf{e}_t, \mathbf{e}_r) \cdot \mathbf{e}_r - \mathbf{e}_t \|_p + d(h, r, t) = - \| \mathbf{e}_h + f(\mathbf{e}_h, \mathbf{e}_t, \mathbf{e}_r) + \cdot \mathbf{e}_r - \mathbf{e}_t \|_p .. note:: For an example of using the :class:`TransF` model, see