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

A bug in aug_random_edge #12

Closed
skydetailme opened this issue Jan 20, 2021 · 10 comments
Closed

A bug in aug_random_edge #12

skydetailme opened this issue Jan 20, 2021 · 10 comments

Comments

@skydetailme
Copy link

Hi, Shen. Thanks for your efforts in this program. I noticed there might have a logical bug in the aug_random_edge function.

“for i in index_list:
single_index_list.append(i)
index_list.remove((i[1], i[0]))”

Removing items in a list while iterating that list may cause problems, as the list changed but the current index is not changed.

This blog illustrated well.
https://thispointer.com/python-remove-elements-from-a-list-while-iterating/

Thanks for your help.

@yyou1996
Copy link
Collaborator

Hi @skydetailme,

Thanks for your interest in our work. Would you mind pointing out which file you are referring to? I think in my implementation I did not use "remove()" function but directly use indexing to modify them, e.g.

edge_index = np.concatenate((edge_index[:, np.random.choice(edge_num, (edge_num - permute_num), replace=False)], idx_add), axis=1)

@skydetailme
Copy link
Author

Hi, thanks for the reply. Here is the link.
https://github.com/Shen-Lab/GraphCL/blob/master/unsupervised_Cora_Citeseer/aug.py

@yyou1996
Copy link
Collaborator

@yongduosui, would you mind giving some comments on this? Thanks!

@yongduosui
Copy link
Collaborator

@skydetailme The aim of this code is to convert to convert bidirectional edges index to unidirectional index. I just debug my code and did't find any bug. It remove the other edge index pair successfully. You can print the list and check. Thanks.

@skydetailme
Copy link
Author

@skydetailme The aim of this code is to convert to convert bidirectional edges index to unidirectional index. I just debug my code and did't find any bug. It remove the other edge index pair successfully. You can print the list and check. Thanks.

Would you mind take some minutes to read the link I posted, it explains well.
And you will find that after this iteration, index_list is not empty, those are the items accidentally jumped because of index error. Those items are not solved.
The result may right on some occasions but this code may not logically right.

@skydetailme
Copy link
Author

@skydetailme The aim of this code is to convert to convert bidirectional edges index to unidirectional index. I just debug my code and did't find any bug. It remove the other edge index pair successfully. You can print the list and check. Thanks.

Also, thanks for your help.

@skydetailme
Copy link
Author

@skydetailme The aim of this code is to convert to convert bidirectional edges index to unidirectional index. I just debug my code and did't find any bug. It remove the other edge index pair successfully. You can print the list and check. Thanks.

It seems that if the adj matrix is self-loop, this code may cause a wrong result, and the index_list is not empty.
If it's not a self-loop adj matrix, the result is right.

@yyou1996
Copy link
Collaborator

@skydetailme Thank you for your carefulness, and I see your point. The citation net datasets happen to be without self-loop. I will read the post and give some comments after finishing my work at hand.

@skydetailme
Copy link
Author

@skydetailme Thank you for your carefulness, and I see your point. The citation net datasets happen to be without self-loop. I will read the post and give some comments after finishing my work at hand.

Thanks for your reply and contribution. This project helps a lot.

@yyou1996
Copy link
Collaborator

yyou1996 commented Feb 6, 2021

Hi @skydetailme,

Sorry for the late reply that I just survive a DDL. I make certain modifications according to the blog u share https://thispointer.com/python-remove-elements-from-a-list-while-iterating/. Thanks again for your carefulness.

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

3 participants