awslabs / dgl-ke

High performance, easy-to-use, and scalable package for learning large-scale knowledge graph embeddings.
https://dglke.dgl.ai/doc/
Apache License 2.0
1.28k stars 196 forks source link

TransR dglke_predict #178

Open FilipKon opened 3 years ago

FilipKon commented 3 years ago

Hi,

I wanted to ask if it is already planned to integrate TransR into dglke_predict. Right now in the documentation, it is said that it isn't so I didn't try it out. Is there any update on it?

Thanks.

Best regards, Filip

classicsong commented 3 years ago

Hi, TransR is not supported right now. Will support it later.

sourav1312 commented 3 years ago

I trained a TransE model and ran the following code snippet for the model prediction -

*DGLBACKEND=pytorch dglke_predict --model_path ckpts/TransE_l1_JapEnc_2/ --format '_r_t' --data_files data/rel.list data/tail.list --score_func logsigmoid --exec_mode 'batch_head' --raw_data --entity_mfile data/entities.tsv --rel_mfile data/relations.tsv**

On running this code, I encountered the following error -

ckpts/TransE_l1_JapEnc_2/config.json {'dataset': 'JapEnc', 'model': 'TransE_l1', 'emb_size': 400, 'max_train_step': 500, 'batch_size': 1000, 'neg_sample_size': 200, 'lr': 0.01, 'gamma': 19.9, 'double_ent': False, 'double_rel': False, 'neg_adversarial_sampling': True, 'adversarial_temperature': 1.0, 'regularization_coef': 2e-08, 'regularization_norm': 3, 'emap_file': 'entities.tsv', 'rmap_file': 'relations.tsv'} Traceback (most recent call last): File "/usr/local/bin/dglke_predict", line 8, in sys.exit(main()) File "/usr/local/lib/python3.7/dist-packages/dglke/infer_score.py", line 216, in main result = model.topK(head, rel, tail, args.exec_mode, args.topK) File "/usr/local/lib/python3.7/dist-packages/dglke/models/infer.py", line 173, in topK F.asnumpy(rel[rel_idx]), IndexError: tensors used as indices must be long, byte or bool tensors

Please help me with how to resolve this issue. Thanks in advance.

zezhongding commented 1 year ago

Hi, TransR is not supported right now. Will support it later.

Is TransR supported now? When I train TransR in my dataset, it comes the following errors. raceback (most recent call last):File "/home4/intern/zzding3/anaconda3/envs/embed/lib/python3.9/multiprocessing/process.py",Line315,inbootstrapself run (File "/home4/intern/zzding3/anaconda3/envs/embed/lib/python3.9/multiprocessing/process.py", line108,in runself. target(*self. args,*self,kwargs)File "/home4/intern/zzding3/.local/lib/python3.9/site-packages/dglke-0.1.0.dev0-py3.9.egg/dglke)models/pytorch/tensor models.py", line 133, in decorated functionraise exception .class(trace)IndexError: Traceback (most recent call last):File "/home4/intern/zzding3/. ocal/lib/python3.9/site-packages/dglke-0.1.0.dev0-py3.9.egg/dglkemodels/pytorch/tensor models .py,line 121,inqueue resultres = func(args,**kwargs)File " /home4/intern/zzding3/.local/lib/python3.9/site-packages/dglke-0.1.0.dev0-py3.9.egg/dglketrain pytorch.py",line 265,in test mptest(args, model, test samplers, rank,mode, queue)File "/home4/intern/zzding3/. ocal/lib/python3.9/site-packages/dglke-0.1.0,dev0-py3.9,egg/dglke)train pytorch.py",line 241, in testmodel.forward test(pos g,neg g, logs, gpu id)File "/home4/intern/zzding3/.local/lib/python3.9/site-packages/dglke-0.1.0.dev0-py3.9.egg/dglke)models/general models .py",line 458,in forward testneg scores = selfpredict neg score(pos g, neg g,to device=cuda,File "/home4/intern/zzding3/.local/lib/python3.9/site-packages/dglke-0,1.0.dev0-py3.9.egg/dglke/models/general models,py", ine 383,in predict neg scoreneg head = selfentity emb(neg head ids, gpu id,trace)File "/home4/intern/zzding3/.local/lib/python3.9/site-packages/dglke-0.1.0.dev0-py3.9.egg/dglkemodels/pytorch/tensor models.py", line 292, incalls = self,emblidx]IndexError: index 62286 is out of bounds for dimension 0 with size 62286