Skip to content

Commit

Permalink
update formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
yukew1998 committed Dec 19, 2024
1 parent f610d00 commit 06a2c5d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 7 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
17 changes: 11 additions & 6 deletions torch_geometric/nn/kge/transf.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 06a2c5d

Please sign in to comment.