ShelkerX 5e120742cf | 1 year ago | |
---|---|---|
.. | ||
README.md | 1 year ago |
$$
f(\textbf{h},\textbf{r},\textbf{t}) = | \textbf{M}{r}\textbf{h}+\textbf{r}-\textbf{M}{r}\textbf{t}|_{2}^{2}
$$
$$
S' = \left { (h',r,t) \right |h'\in E } \cup \left { (h,r,t') \right |t'\in E }
$$
$$
Loss = \sum_{(\textbf{h},\textbf{r},\textbf{t}) \in S}\sum_{(\textbf{h}',\textbf{r},\textbf{t}') \in S'}[\gamma - f(\textbf{h},\textbf{r},\textbf{t}) + f(\textbf{h}',\textbf{r},\textbf{t}')]_{+}
$$
Finally, use BP to update the model.
In addition, CTransR uses the results of TransE to pre cluster entities, and then learns a relationship vector $ \textbf{r}_{c} $ for each cluster. The new loss is as follows:
$$
f_{r}(h,t)=| \textbf{M}{r}\textbf{h}+\textbf{r}-\textbf{M}{r}\textbf{t} |{2}^{2} + \alpha | \textbf{r}{c}-\textbf{r} |_{2}^{2}
$$
Clone the Openhgnn-DGL
# For link prediction task
python main.py -m TransR -t link_prediction -d FB15k -g 0 --use_best_config
If you do not have gpu, set -gpu -1.
Number of entities and relations
entities | relations |
---|---|
14,951 | 1,345 |
Size of dataset
set type | size |
---|---|
train set | 483,142 |
validation set | 50,000 |
test set | 59,071 |
Number of entities and relations
entities | relations |
---|---|
40,493 | 18 |
Size of dataset
set type | size |
---|---|
train set | 141,442 |
validation set | 5,000 |
test set | 5,000 |
Evaluation metric: mrr
Testing model performance...
You can modify the parameters[TransE] in openhgnn/config.ini
Xiaoke Yang
Submit an issue or email to x.k.yang@qq.com.
OpenHGNN是由北邮GAMMA Lab开发的基于PyTorch和DGL的开源异质图神经网络工具包。
Python Markdown Shell
Dear OpenI User
Thank you for your continuous support to the Openl Qizhi Community AI Collaboration Platform. In order to protect your usage rights and ensure network security, we updated the Openl Qizhi Community AI Collaboration Platform Usage Agreement in January 2024. The updated agreement specifies that users are prohibited from using intranet penetration tools. After you click "Agree and continue", you can continue to use our services. Thank you for your cooperation and understanding.
For more agreement content, please refer to the《Openl Qizhi Community AI Collaboration Platform Usage Agreement》