Giter Club home page Giter Club logo

kgat-pytorch's People

Contributors

luna-fu avatar lunablack avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

kgat-pytorch's Issues

train1.txt

請問train1.txt與train.txt差異為何?
在什麼地方有使用到?
謝謝

RunTimeError

I run the code with yelp2018 dataset ,but an error occurred in epoch2

2021-03-22 17:14:01,766 - root - INFO - KG Training: Epoch 0002 Total Iter 2719 | Total Time 241.7s | Iter Mean Loss 0.0315
2021-03-22 17:14:01,766 - root - INFO - CF + KG Training: Epoch 0002 | Total Time 470.4s
Traceback (most recent call last):
File "main_kgat.py", line 286, in
train(args)
File "main_kgat.py", line 196, in train
_, precision, recall, ndcg = evaluate(model, train_graph, data.train_user_dict, data.test_user_dict, user_ids_batches, item_ids, args.K)
File "main_kgat.py", line 41, in evaluate
cf_scores_batch = model('predict', train_graph, user_ids_batch, item_ids) # (n_batch_users, n_eval_items)
File "/opt/miniconda3/envs/zsx_dgl/lib/python3.6/site-packages/torch/nn/modules/module.py", line 550, in call
result = self.forward(*input, **kwargs)
File "/home/user18/zsx/GraduationProj/KGAT-pytorch/model/KGAT.py", line 224, in forward
return self.cf_score(mode, *input)
File "/home/user18/zsx/GraduationProj/KGAT-pytorch/model/KGAT.py", line 188, in cf_score
cf_score = torch.matmul(user_embed, item_embed.transpose(0, 1)) # (n_eval_users, n_eval_items)

RuntimeError: CUDA out of memory. Tried to allocate 1.70 GiB (GPU 0; 31.71 GiB total capacity; 10.63 GiB already allocated; 597.12 MiB free; 12.47 GiB reserved in total by PyTorch)

About the poor performance..

Hi, this is a good implementation! And I am not criticizing the original paper, but as this rebuilding work shows, the recommendation performance on top-20 hit ratio (which is precision in metrics) is really poor, only ~1%... which is really surprising!

I also rerun this code and get similar results, and I'm just curious that, if recommending performance is in such a way, how can we ensure these kinds of systems useful?

By the way, this is not a criticism about these creative works and implementation, just surprising about the low hit ratio and hope to receive some open-mind discussion with you talented guys, thanks :D

Questions about FM and NFM

Why do I run FM and NFM with full memory in the calculation phase?

Are you sure your code will work?

Look forward to your reply

程式碼與論文設計不同

作者您好,想請問一下為何程式碼當中kg 和cf是分開訓練?論文裡面是合在一起訓練。以及deacy factor的初始化跟論文也不太一樣,謝謝!!

How to test?

You have the test_graph defined in your code, but I don't see where it is used in the code.The test users were evaluated in function evaluate. Is this test_graph unnecessary?

performance and time cost

你好,我用你的代码(默认设置)跑程序(gtx1050ti),差不多20分钟一个epoch。问题是性能很低啊,不足1% @recall。请问您用的什么参数配置跑出您声称的性能的

questions about kg_final.txt

I am currently working with the dataset that includes the "kg_final.txt" file, and I am seeking some clarification regarding its contents and usage.

Data Contents: Could you please provide detailed information about the contents of kg_final.txt ? Specifically, I am interested in understanding the type of data it contains and the format of this data.

Relation to Items/Users: How does the data in kg_final.txt relate to the items and users in the dataset? Is there a direct correlation or mapping that links the entities in kg_final.txt to specific users or items?

Generation Process: Additionally, I would appreciate if you could shed some light on how kg_final.txt was generated. What sources and methodologies were used to compile this data?

About unpretrained training

Thanks for your implementation. I have run your codes in both pretrained and unpretrained mode. I have a question that do you have tried the unpretrained mode? It seems that the results are extremely bad. The pretrained version is ok and the results of early epochs are close to those of the authors' TF version. But the unpretrained one is far worse than the unpretrained TF version.

In my machine, I got an early stop at epoch 20, with the evaluation metrics as follows:

2020-08-26 16:44:12,377 - root - INFO - CF Evaluation: Epoch 0020 | Total Time 148.6s | Precision-k 0.0002970381 Recall-k 0.0003790736 NDCG-k 0.0003935562

Would you please suggest any reasons for these? Could it mainly because of the early stop part? Any suggestions will be much appreciated and look forward to your reply! Thank you!

Reharding kg_final.txt file generation

Hi ,
Amazing work on adapting kgat on pytorch.
Can u please help on how the kg_final.txt file is generated - how are the triplets formed? Is it item to item relation?
Thanks in advance

Question on the TransR projection

In the model KGAT,

r_mul_t = torch.matmul(self.entity_user_embed(edges.src['id']), self.W_r) # (n_edge, relation_dim)

It is written as below.

r_mul_t = torch.matmul(self.entity_user_embed(edges.src['id']), self.W_r)                       # (n_edge, relation_dim)
r_mul_h = torch.matmul(self.entity_user_embed(edges.dst['id']), self.W_r)                       # (n_edge, relation_dim)

I think (h,r,t) means (head, relation to tail, tail) which means head is source.
So isn't it right to write as below?

r_mul_h = torch.matmul(self.entity_user_embed(edges.src['id']), self.W_r)                       # (n_edge, relation_dim)
r_mul_t = torch.matmul(self.entity_user_embed(edges.dst['id']), self.W_r)                       # (n_edge, relation_dim)

Why performances are not aligned with original work?

Hi! Congrats on the well-written implementation of this codebase, which really needed a more understandable version. Although being the evaluation side equal to the original, you should get results very similar(almost equal) to them. Have you wondered why this is not happening? Have you done any simplification that could have degraded the performances? Have you changed anything in the dataset? There is a gap of 0.25 points of NDCG@20 for amazon-book between your evaluation and the original one, which is pretty high

problem

Sorry my friend, I am learning about KGAT, I currently have a problem that cannot be solved, I hope to get your help

image

Question on the kgat

In the model KGAT,
KGAT-pytorch/model/KGAT.py

It is written as below.
user_embed = all_embed[user_ids]

I think user_ids should plus n_entities
so isn't it right to write as below?
user_embed = all_embed[user_ids + self.entities]

关于用户嵌入和项目嵌入问题

感谢您提供KGAT的pytorch ,在运行时我发现Amazon-book的user_embedding的数量为70591,item_embedding的数量为24915和项目的数量一致,可以请问一下为什么用户的嵌入的数量和用户的数量不一致吗?

OSError: [WinError 1114] 动态链接库(DLL)初始化例程失败。 Error loading "D:\SoftWares\Python3.12.0\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies.

运行python main_nfm.py --model_type fm --data_name amazon-book报错:
Traceback (most recent call last):
File "", line 1, in
File "D:\SoftWares\Python3.12.0\Lib\multiprocessing\spawn.py", line 122, in spawn_main
exitcode = _main(fd, parent_sentinel)
^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\SoftWares\Python3.12.0\Lib\multiprocessing\spawn.py", line 131, in _main
prepare(preparation_data)
File "D:\SoftWares\Python3.12.0\Lib\multiprocessing\spawn.py", line 246, in prepare
_fixup_main_from_path(data['init_main_from_path'])
File "D:\SoftWares\Python3.12.0\Lib\multiprocessing\spawn.py", line 297, in _fixup_main_from_path
main_content = runpy.run_path(main_path,
^^^^^^^^^^^^^^^^^^^^^^^^^
File "", line 286, in run_path
File "", line 98, in _run_module_code
File "", line 88, in run_code
File "D:\Graduate\Codes\Knowledge Graph recommend\KGAT-pytorch-master\main_nfm.py", line 9, in
import torch.nn as nn
File "D:\SoftWares\Python3.12.0\Lib\site-packages\torch_init
.py", line 130, in
raise err
OSError: [WinError 1114] 动态链接库(DLL)初始化例程失败。 Error loading "D:\SoftWares\Python3.12.0\Lib\site-packages\torch\lib\shm.dll" or one of its dependencies.

导包

Import only needed names or import the module and then use its members.
我一直在提示这个错误,运行提示ModuleNotFoundError: No module named 'parser.parser_ecfkg'; 'parser' is not a package
请问这是什么原因导致的?

运行python main_nfm.py --model_type fm --data_name amazon-book报错

(relation_embed): Embedding(80, 64)
(entity_user_embed): Embedding(184166, 64)
File "D:\Graduate\Codes\Knowledge Graph recommend\KGAT-pytorch-master\main_ecfkg.py", line 116, in train
batch_head, batch_relation, batch_pos_tail, batch_neg_tail = data.generate_kg_batch(data.train_kg_dict, data.train_batch_size, data.n_users_entities)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\Graduate\Codes\Knowledge Graph recommend\KGAT-pytorch-master\data_loader\loader_base.py", line 153, in generate_kg_batch
batch_head = random.sample(exist_heads, batch_size)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "D:\SoftWares\Python3.12.0\Lib\random.py", line 413, in sample
raise TypeError("Population must be a sequence. "
TypeError: Population must be a sequence. For dicts or sets, use sorted(d).

运行

你好,我在运行main_kgat.py时候,为什么报错
File "C:\Users\zheny\Anaconda3\lib\ctypes_init_.py", line 364, in init
self._handle = _dlopen(self._name, mode)
OSError: [WinError 126] 找不到指定的模块。
还请解答

cannot run with GPU

这个代码用cpu可以正常的跑,但是用GPU就会报下面的错,想知道怎么解决,有没有小伙伴遇到了同样的问题

Traceback (most recent call last):
File "main_kgat.py", line 287, in
train(args)
File "main_kgat.py", line 141, in train
att = model('calc_att', train_graph)
File "/opt/conda/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in call
result = self.forward(*input, **kwargs)
File "/data/KGAT-pytorch/model/KGAT.py", line 218, in forward
return self.compute_attention(*input)
File "/data/KGAT-pytorch/model/KGAT.py", line 125, in compute_attention
g.apply_edges(self.att_score, edge_idxs)
File "/opt/conda/lib/python3.7/site-packages/dgl/graph.py", line 2148, in apply_edges
Runtime.run(prog)
File "/opt/conda/lib/python3.7/site-packages/dgl/runtime/runtime.py", line 11, in run
exe.run()
File "/opt/conda/lib/python3.7/site-packages/dgl/runtime/ir/executor.py", line 204, in run
udf_ret = fn_data(src_data, edge_data, dst_data)
File "/opt/conda/lib/python3.7/site-packages/dgl/runtime/scheduler.py", line 949, in _mfunc_wrapper
return mfunc(ebatch)
File "/data/KGAT-pytorch/model/KGAT.py", line 113, in att_score
r_mul_h = torch.matmul(self.entity_user_embed(edges.src['id']), self.W_r) # (n_edge, relation_dim)
RuntimeError: CUDA error: CUBLAS_STATUS_EXECUTION_FAILED when calling cublasSgemm( handle, opa, opb, m, n, k, &alpha, a, lda, b, ldb, &beta, c, ldc)

A problem that I cant run this code

Hello,author. When I ran your codes, there was an error:
~/notebooks/ZY/KGAT/main_kgat.py in train(args)
113 train_nodes = train_nodes.to(device)
114 train_edges = train_edges.to(device)
--> 115 train_graph.ndata['id'] = train_nodes.to(device)
116 train_graph.edata['type'] = train_edges.to(device)
DGLError: Cannot assign node feature "id" on device cuda:0 to a graph on device cpu. Call DGLGraph.to() to copy the graph to the same device.

Can you help me? Thank you very much.

Why inverse kg data?

For every [h,r,t], you seem add [t,r,h] to the kg. What is this step's meaning? Is that gonna change directed graph to undirected graph and then influence the TransR?

关于实验结果

您好,感谢您这么棒的工作,我想问下不使用pre_train的embedding加载的话,您有试过吗,我尝试跑yelp数据,不加载embedding的话,前10几轮的指标特别低,而且没有上涨的趋势,谢谢!

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.