Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Train_TransE.cpp在训练过程中存在内存泄漏的问题 #5

Closed
cdzhan opened this issue Oct 24, 2016 · 5 comments
Closed

Train_TransE.cpp在训练过程中存在内存泄漏的问题 #5

cdzhan opened this issue Oct 24, 2016 · 5 comments

Comments

@cdzhan
Copy link

cdzhan commented Oct 24, 2016

您好,
在调用函数bfgs()训练时内存不断增长,感觉应该是发生了内存泄漏,可是没有找到原因。因为我用的freebase知识库比较大,所以内存占用很严重。您有什么建议吗?

@Mrlyk423
Copy link
Member

你好,TransE训练中以下句子可能会在训练过程中使得内存增长:
while (ok[make_pair(j,fb_r[i])].count(fb_l[i])>0)
j=rand_max(entity_num);
该句子用于判断产生的负例是否和已有正例冲突,可以改为:
if (ok.count(make_pair(j,fb_r[i]))>0)
while (ok[make_pair(j,fb_r[i])].count(fb_l[i])>0)
j=rand_max(entity_num);

@cdzhan
Copy link
Author

cdzhan commented Oct 24, 2016

嗯,问题解决了,谢谢你。另外,我觉得在while循环体内再加入一条判断语句
while (ok[make_pair(j,fb_r[i])].count(fb_l[i])>0)

j=rand_max(entity_num);
if (ok.count(make_pair(j,fb_r[i]))==0)
break;

是不是更好?

@Mrlyk423
Copy link
Member

对的。

@guotong1988
Copy link

代码里的fb是freebase的意思吧?

@zhangyi85
Copy link

我在windows环境下遇到过,查了半天没查出问题,在prepare过程中,有file f1,file f2open后,没有close,添加了两条close语句后,貌似内存泄漏的问题没出现了。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants