Lancelot39/KGSF

你好,我想请教下代码的一些细节问题

Opened this issue · 34 comments

1、max-r-length和max-c-length表示什么意思呢

2、是不是train_data.jsonl语料中的一些电影没有在id2entity.pkl收录呢,我打断点调试到dataset.py文件里detect_movice()函数中,发现entity = self.id2entity[int(movie)]有时返回为空...

而且调试到utils.py中_create_embeddings()函数时,发现也没有word2vec_redial.npy文件..

另外我在代码里找不到公式3、4、9中提到的互信息最大化损失对应的位置..

你好,我想麻烦问一下您,您是用作者要求的pytorch==1.3.0,torch_geometric==1.3.2进行训练的吗?现在这两个版本已经没有了,我不太知道如何能够配好正确的环境。期待您的回复,谢谢!

你好,我想麻烦问一下您,您是用作者要求的pytorch==1.3.0,torch_geometric==1.3.2进行训练的吗?现在这两个版本已经没有了,我不太知道如何能够配好正确的环境。期待您的回复,谢谢!

我的环境是1.6.1的torch-geometric和1.6.0+cu101的pytorch

哦哦,那您能成功运行是吗?

哦哦,那您能成功运行是吗?

可以训练并计算损失函数,还没整完:
3%|█▎ | 50/1616 [00:31<16:13, 1.61it/s]info db loss is 8.705469
6%|██▍ | 100/1616 [01:02<15:41, 1.61it/s]info db loss is 1.966950
9%|███▋ | 150/1616 [01:34<15:11, 1.61it/s]info db loss is 1.705429
12%|████▉ | 200/1616 [02:05<14:40, 1.61it/s]info db loss is 1.738045
15%|██████▏ | 250/1616 [02:36<14:08, 1.61it/s]info db loss is 1.594990
19%|███████▍ | 300/1616 [03:07<13:37, 1.61it/s]info db loss is 1.417708
22%|████████▋ | 350/1616 [03:38<13:06, 1.61it/s]info db loss is 1.397896
25%|█████████▉ | 400/1616 [04:09<12:35, 1.61it/s]info db loss is 1.399305
28%|███████████▏ | 450/1616 [04:40<12:04, 1.61it/s]info db loss is 1.504028
31%|████████████▍ | 500/1616 [05:11<11:33, 1.61it/s]info db loss is 1.447741
34%|█████████████▌ | 550/1616 [05:42<11:02, 1.61it/s]info db loss is 1.490247

好的,太感谢啦!

好的,太感谢啦!

不客气

您好,您是已经训练了多久还没整完?我看您九月份就开始运行代码了

您好,您是已经训练了多久还没整完?我看您九月份就开始运行代码了

估计得一下午。我是从九月份阅读论文复现实验的,但是没有仔细研究,因为十月份我换了方向了

好我刚刚关注了您的博客 我是河北人 哈哈离得很近呢!谢谢

好我刚刚关注了您的博客 我是河北人 哈哈离得很近呢!谢谢

没事儿

{'recall@1': 0.03322259136212625, 'recall@10': 0.20066445182724252, 'recall@50': 0.412624584717608, 'loss': tensor(6.9143, device='cuda:0'), 'gate': 0.0, 'count': 1.0, 'gate_count': 0.0}
Traceback (most recent call last):
File "run.py", line 687, in
loop.train()
File "run.py", line 217, in train
self.model.save_model()
File "/home/ubuntu/KGSF-master/KGSF-master/model.py", line 540, in save_model
torch.save(self.state_dict(), 'saved_model/net_parameter1.pkl')
File "/home/ubuntu/anaconda3/envs/tan18/lib/python3.8/site-packages/torch/serialization.py", line 369, in save
with _open_file_like(f, 'wb') as opened_file:
File "/home/ubuntu/anaconda3/envs/tan18/lib/python3.8/site-packages/torch/serialization.py", line 230, in _open_file_like
return _open_file(name_or_buffer, mode)
File "/home/ubuntu/anaconda3/envs/tan18/lib/python3.8/site-packages/torch/serialization.py", line 211, in init
super(_open_file, self).init(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: 'saved_model/net_parameter1.pkl'

你好~请问您第一阶段训练完后是这种结果吗?有没有出现这个找不到文件的错误呢

{'recall@1': 0.03322259136212625, 'recall@10': 0.20066445182724252, 'recall@50': 0.412624584717608, 'loss': tensor(6.9143, device='cuda:0'), 'gate': 0.0, 'count': 1.0, 'gate_count': 0.0}
Traceback (most recent call last):
File "run.py", line 687, in
loop.train()
File "run.py", line 217, in train
self.model.save_model()
File "/home/ubuntu/KGSF-master/KGSF-master/model.py", line 540, in save_model
torch.save(self.state_dict(), 'saved_model/net_parameter1.pkl')
File "/home/ubuntu/anaconda3/envs/tan18/lib/python3.8/site-packages/torch/serialization.py", line 369, in save
with _open_file_like(f, 'wb') as opened_file:
File "/home/ubuntu/anaconda3/envs/tan18/lib/python3.8/site-packages/torch/serialization.py", line 230, in _open_file_like
return _open_file(name_or_buffer, mode)
File "/home/ubuntu/anaconda3/envs/tan18/lib/python3.8/site-packages/torch/serialization.py", line 211, in init
super(_open_file, self).init(open(name, mode))
FileNotFoundError: [Errno 2] No such file or directory: 'saved_model/net_parameter1.pkl'

你好~请问您第一阶段训练完后是这种结果吗?有没有出现这个找不到文件的错误呢
会报这种错误,所以我把is_finetune参数默认设为false(run.py第70行左右),具体原因你可以查一下saved_model/net_parameter1.pkl在哪儿出现,这个文件被加载时的调用栈是如何的

train.add_argument("-is_finetune","--is_finetune",type=bool,default=False)

谢谢!您改完之后就好了吗?可是我看源码里本来就是false?

train.add_argument("-is_finetune","--is_finetune",type=bool,default=False)

谢谢!您改完之后就好了吗?可是我看源码里本来就是false?

对不住漏看了,还要把TrainLoop_fusion_rec类的train()方法中第一行self.model.load_model()给注释掉(run.py第154行左右)。以及下面代码里,注释掉false分支中的load_model()调用:

    if args.is_finetune == False:
        loop = TrainLoop_fusion_rec(vars(args), is_finetune=False)
        # loop.model.load_model()  # 注释这儿
        loop.train()
    else:
        loop = TrainLoop_fusion_gen(vars(args), is_finetune=True)
        # loop.train()
        loop.model.load_model()
        # met = loop.val(True)
        loop.train()
    met = loop.val(True)

这样只有当is_finetune为真时,才会执行下面的分支,加载之前的模型。

好的真的太感谢您了,可是刚刚您说的这几处 我下载的源代码里好像已经注释好了。我是在第一阶段训练到最后save时
File "run.py", line 217, in train self.model.save_model()
报找不到文件的错误
File "run.py", line 687, in loop.train() File "run.py", line 217, in train self.model.save_model() File "/home/ubuntu/KGSF-master/KGSF-master/model.py", line 540, in save_model torch.save(self.state_dict(), 'saved_model/net_parameter1.pkl') File "/home/ubuntu/anaconda3/envs/tan18/lib/python3.8/site-packages/torch/serialization.py", line 369, in save with _open_file_like(f, 'wb') as opened_file: File "/home/ubuntu/anaconda3/envs/tan18/lib/python3.8/site-packages/torch/serialization.py", line 230, in _open_file_like return _open_file(name_or_buffer, mode) File "/home/ubuntu/anaconda3/envs/tan18/lib/python3.8/site-packages/torch/serialization.py", line 211, in init super(_open_file, self).init(open(name, mode)) FileNotFoundError: [Errno 2] No such file or directory: 'saved_model/net_parameter1.pkl'
这个保存时找不到文件的话不应该是自己创建一个吗?`

好的真的太感谢您了,可是刚刚您说的这几处 我下载的源代码里好像已经注释好了。我是在第一阶段训练到最后save时
File "run.py", line 217, in train self.model.save_model()
报找不到文件的错误
File "run.py", line 687, in loop.train() File "run.py", line 217, in train self.model.save_model() File "/home/ubuntu/KGSF-master/KGSF-master/model.py", line 540, in save_model torch.save(self.state_dict(), 'saved_model/net_parameter1.pkl') File "/home/ubuntu/anaconda3/envs/tan18/lib/python3.8/site-packages/torch/serialization.py", line 369, in save with _open_file_like(f, 'wb') as opened_file: File "/home/ubuntu/anaconda3/envs/tan18/lib/python3.8/site-packages/torch/serialization.py", line 230, in _open_file_like return _open_file(name_or_buffer, mode) File "/home/ubuntu/anaconda3/envs/tan18/lib/python3.8/site-packages/torch/serialization.py", line 211, in init super(_open_file, self).init(open(name, mode)) FileNotFoundError: [Errno 2] No such file or directory: 'saved_model/net_parameter1.pkl'
这个保存时找不到文件的话不应该是自己创建一个吗?`

保存时报的错?那就把保存的代码也注释掉,备不住得自己创建saved_model目录

好的谢谢!!您没有遇到这个问题是吗?把保存的代码也注释掉?可是之后训练的第二阶段(is_finetune==True)不会从里面加载模型吗?

好的谢谢!!您没有遇到这个问题是吗?把保存的代码也注释掉?可是之后训练的第二阶段(is_finetune==True)不会从里面加载模型吗?

我印象里也遇到过文件找不到的错误,但记不清是不是这个文件或文件夹了。不过我一般关注的是模型能不能正常训练和测试,以及数据预处理、模型的内部结构和训练的逻辑。所以关于状态的保存与读取,我还真没操多少心。

好的~~谢谢您!!

您好,对不起又打扰您了,请问您训练的第二阶段(python run.py --is_finetune True)训练了大概多久呢?

您好,对不起又打扰您了,请问您训练的第二阶段(python run.py --is_finetune True)训练了大概多久呢?

不知道,我没进行过完整的训练。如果再有问题电邮交流吧,我邮箱392004248@qq.com,省得我还得跳过来~

好我刚刚关注了您的博客 我是河北人 哈哈离得很近呢!谢谢

您好 ,想请教一下您关于运行的问题,请问方便和您邮件交流吗

您好,对不起又打扰您了,请问您训练的第二阶段(python run.py --is_finetune True)训练了大概多久呢?

想麻烦问下您 这个大概是训练多久呢

is there any update on how long it toook to run the above code ?

方是方便,只是这个项目代码我已经记不起上次是什么时候看的了,不见得能回答了所有疑问

------------------ 原始邮件 ------------------ 发件人: "Lancelot39/KGSF" @.>; 发送时间: 2022年1月4日(星期二) 晚上11:08 @.>; @.@.>; 主题: Re: [Lancelot39/KGSF] 你好,我想请教下代码的一些细节问题 (#3) 好我刚刚关注了您的博客 我是河北人 哈哈离得很近呢!谢谢 您好 ,想请教一下您关于运行的问题,请问方便和您邮件交流吗 — Reply to this email directly, view it on GitHub, or unsubscribe. Triage notifications on the go with GitHub Mobile for iOS or Android. You are receiving this because you authored the thread.Message ID: @.***>

您好,我想请教您个问题[Errno 2] No such file or directory: 'word2vec_redial.npy'请问这个文件怎么弄?求指教

您好,对不起又打扰您了,请问您训练的第二阶段(python run.py --is_finetune True)训练了大概多久呢?

你好,我能加您一个联系方式吗?我想请教你一下这个KGSF代码的问题

哦哦,那您能成功运行是吗?

我能加你个联系方式,请教一些问题吗?

而且调试到utils.py中_create_embeddings()函数时,发现也没有word2vec_redial.npy文件..

请问这个问题怎么解决的?

好的,太感谢啦!

Hello, I ran the code and reported that No module named 'project' could not be found. How can I solve this problem?

而且调试到utils.py中_create_embeddings()函数时,发现也没有word2vec_redial.npy文件..

请问这个问题怎么解决的?

@LoveAnneke README 里面有个 link 可以下载这个文件

另外一个方法就是 uncomment dataset.py 里的 Line 43

#self.prepare_word2vec()

def prepare_word2vec(self):

会去生成那个文件

好的真的太感谢您了,可是刚刚您说的这几处 我下载的源代码里好像已经注释好了。我是在第一阶段训练到最后save时 报找不到文件的错误 这个保存时找不到文件的话不应该是自己创建一个吗?File "run.py", line 217, in train self.model.save_model() ``File "run.py", line 687, in loop.train() File "run.py", line 217, in train self.model.save_model() File "/home/ubuntu/KGSF-master/KGSF-master/model.py", line 540, in save_model torch.save(self.state_dict(), 'saved_model/net_parameter1.pkl') File "/home/ubuntu/anaconda3/envs/tan18/lib/python3.8/site-packages/torch/serialization.py", line 369, in save with _open_file_like(f, 'wb') as opened_file: File "/home/ubuntu/anaconda3/envs/tan18/lib/python3.8/site-packages/torch/serialization.py", line 230, in _open_file_like return _open_file(name_or_buffer, mode) File "/home/ubuntu/anaconda3/envs/tan18/lib/python3.8/site-packages/torch/serialization.py", line 211, in init super(_open_file, self).init(open(name, mode)) FileNotFoundError: [Errno 2] No such file or directory: 'saved_model/net_parameter1.pkl'

您好,我目前也遇到了这个问题,不知道您还记得当时是怎么解决的吗,如果您还保留这个代码的话,希望可以分享给我一下,谢谢!我的邮箱地址是1917632882@qq.com