-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
💃 🔱 Add HAKE Interaction #442
base: master
Are you sure you want to change the base?
Conversation
tests/test_nn/test_modules.py
Outdated
# remove batch/num dimension | ||
h_phase, h_modulus, r_phase, r_modulus, r_bias, t_phase, t_modulus = strip_dim( | ||
h_phase, h_modulus, r_phase, r_modulus, r_bias, t_phase, t_modulus) | ||
r_bias = r_bias.clamp(max=1) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is copy-paste from the interaction function. Is there a better way to do this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If there isn't a more clever way to test the scoring works properly without re-writing the interaction function itself, this test isn't super useful anyway :/
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It checks against broadcasting issues (although this could also be done directly on the functional form).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although it only looks at the case of a tensor of shape (1,1,1,1,*d)
vs. (*d)
🤔
Trigger CI
Trigger CI
Trigger CI
|
||
The score function is given as | ||
|
||
.. math :: | ||
\|\sin ((h + r - t)/2)\|_p | ||
""" | ||
return negative_norm((0.5 * (h + r - t)).sin(), **kwargs) | ||
return negative_norm((0.5 * (h + r - t)).sin(), p=p, power_norm=power_norm) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@cthoyt I did not yet verify that this is indeed the variant from Sun, but rather took this from the HAKE paper, where the authors claim this is the pRotate variant from Sun.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
score = norm(sin(h + r - t)) * modulus
, where modulus is a global parameter. So it is not exactly the same as the Sun variant.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
then let's provide both possible implementations. The trick will be to pick names that are not confusing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Your version can be BRotatE ;)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So can we parametrize the 0.5 and also an outer multipler then have a single general interaction?
.. math :: | ||
\|h \odot r - t\| | ||
|
||
# TODO: this is like a real RotatE. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO
@ralphabb would you be interested in giving this PR a review? |
Sorry, I can't :(. I have a backlog to clear and some deadlines coming up. |
No problem, deadlines are the student's best defense against doing stuff they don't want to! It would be great to plan a video call sometime, if you'd like |
This PR adds the HAKE and ModE interaction functions and modules to PyKEEN.
Learning Hierarchy-Aware Knowledge Graph Embeddings for Link Prediction.
Zhanqiu Zhang, Jianyu Cai, Yongdong Zhang, Jie Wang.
AAAI 2020
Paper @ AAAI / Preprint @ Arxiv / Official Implementation (PyTorch)
It closes #11, or at least the interaction function component of it. It does not provide the exact experimental configuration to reproduce their results.
This PR also adds the pRotatE (from Sun et al. 2019) interaction function and module, since HAKE is based on it.