环境配置:
conda create -n neuralkg python=3.8
conda activate neuralkg
pip install torch==1.9.1+cu111 -f https://download.pytorch.org/whl/torch_stable.html
pip install dgl-cu111 dglgo -f https://data.dgl.ai/wheels/repo.html
pip install neuralkg
!
conda install cudatoolkit
git clone https://github.com/zjukg/NeuralKG.git
cd NeuralKG
python setup.py install
在main.py文件最上方添加:
import sys
sys.path.insert(0,"./src")
Training
# Use bash script
sh ./scripts/your-sh# Use config
python main.py --load_config --config_path <your-config>
以SEGNN为例:
修改配置文件
修改./scripts/FreeBase/SEGNN_FB.sh中NUM_WORKERS(如10->4)
vim ./scripts/FreeBase/SEGNN_FB.sh
运行
# Use bash script
sh ./scripts/FreeBase/SEGNN_FB.sh
# Use config
python main.py --load_config --config_path ./config/FreeBase/SEGNN_FB15K237.yaml
Evaluation
python main.py --test_only --checkpoint_dir <your-model-path>