jiaxuanyou / p-gnn Goto Github PK
View Code? Open in Web Editor NEWPosition-aware Graph Neural Networks
License: MIT License
Position-aware Graph Neural Networks
License: MIT License
In utils.py, preselect_anchor is implemented as following.
def preselect_anchor(data, layer_num=1, anchor_num=32, anchor_size_num=4, device='cpu'):
data.anchor_size_num = anchor_size_num
data.anchor_set = []
anchor_num_per_size = anchor_num//anchor_size_num
for i in range(anchor_size_num):
anchor_size = 2**(i+1)-1
anchors = np.random.choice(data.num_nodes, size=(layer_num,anchor_num_per_size,anchor_size), replace=True)
data.anchor_set.append(anchors)
data.anchor_set_indicator = np.zeros((layer_num, anchor_num, data.num_nodes), dtype=int)
anchorset_id = get_random_anchorset(data.num_nodes,c=1)
data.dists_max, data.dists_argmax = get_dist_max(anchorset_id, data.dists, device)
These but other code uses data.dists_max, dists_argmax , so anchorset_id is used to make them.
But data.anchor_set are not used in other codes..
Do you have reasons you implemented them?
In the paper, it says the lth P-GNN layer first samples k random anchor-sets...
I noticed that you called two sampling functions in the preselect_anchor
function. One is for each layer and the other is resampled only once.
In the P-GNN
model, these three lines are calling the same anchor sets. line 1, line 2, line 3.
Any idea on this?
Hi, @JiaxuanYou
Thank you for sharing your code.
When I tried to run your code with python main.py --model GCN --layer_num 3 --dataset grid
, it gave such error:
Traceback (most recent call last):
File "main.py", line 101, in <module>
out = model(data)
File "/media/newhd/my_path/anaconda3/envs/pt1.0/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in
__call__
result = self.forward(*input, **kwargs)
File "/media/newhd/my_path/project/P-GNN/model.py", line 133, in forward
x = self.conv_first(x, edge_index)
File "/media/newhd/my_path/anaconda3/envs/pt1.0/lib/python3.7/site-packages/torch/nn/modules/module.py", line 532, in
__call__
result = self.forward(*input, **kwargs)
File "/media/newhd/my_path/anaconda3/envs/pt1.0/lib/python3.7/site-packages/torch_geometric/nn/conv/gcn_conv.py", line 99, in forward
return self.propagate(edge_index, x=x, norm=norm)
File "/media/newhd/my_path/anaconda3/envs/pt1.0/lib/python3.7/site-packages/torch_geometric/nn/conv/message_passing.py", line 100, in propagate
out = scatter_(self.aggr, out, edge_index[i], dim_size=size[i])
File "/media/newhd/my_path/anaconda3/envs/pt1.0/lib/python3.7/site-packages/torch_geometric/utils/scatter.py", line 28, in scatter_
out = op(src, index, 0, None, dim_size, fill_value)
RuntimeError: scatter_add() expected at most 5 argument(s) but received 6 argument(s). Declaration: scatter_add(Tensor src, Tensor index, int dim=-1, Tensor? out=None, int? dim_size=None) -> (Tensor)
Seems like it has something to do with the scatter_add
in torch_geometric
. However, mine is 1.1.2
like yours. ( I've also tried several other versions, none works)
So, do you have any idea how to solve this? Thank you again.
Thanks for providing the code. Could you please help me to find the node classification implementation?
-Javid
@JiaxuanYou, I have been reading your code and paper.
I still have trouble to understand if it could fit for my project.
I am currently working on https://github.com/loicland/superpoint_graph.
The main idea is to cut the point cloud into SuperPoint, connect them using Delaunay Triangulation and them learn embeddings for each one of those SuperPoint (pointNet + ECC GraphConv) in order to predict the class.
I was wondering if you could see any use of your research within mine ?
Best,
Thomas Chaton.
Hi~ JiaxuanYou. thanks for your great work. Recently i read your paper. But when i read the chapter "Expressive Power of P-GNNs", i don's understand the end in that chapter says that "join distribution of their distances to comman anchers have more expressive power than existing GNNs.",is it conflict with the sentence "Optimizing Equations 4 and 5 gives representations of nodes using joint and marginal distributions over node embeddings, respectively."
I look forward to your reply
Hi Jianxuan,
Thanks for sharing this great project. I just follow your paper of P-GNN and notice that the functions of "preselect_anchor" and "get_dist_max" may have problems.
data.anchor_size_num = anchor_size_num
data.anchor_set = []
anchor_num_per_size = anchor_num//anchor_size_num
for i in range(anchor_size_num):
anchor_size = 2**(i+1)-1
anchors = np.random.choice(data.num_nodes, size=(layer_num, anchor_num_per_size, anchor_size), replace=True)
data.anchor_set.append(anchors)
data.anchor_set_indicator = np.zeros((layer_num, anchor_num, data.num_nodes), dtype=int)
dist_argmax[:,i] = dist_argmax_temp
, however, dist_argmax_temp seems to be the index of the temp_id while not the index of the node id.The two above questions seem not so aligned with your paper. Do I have some misunderstanding of your paper, or I do not understand your code correctly?
Kind Regard,
Jilin
Hello @JiaxuanYou,
Thank you for the code.
I am trying to run python main.py --model PGNN --layer_num 2 --dataset grid
However, it gives the following error:
File "main.py", line 51, in <module>
data_list = get_tg_dataset(args, dataset_name, use_cache=args.cache, remove_feature=args.rm_feature)
File "P-GNN/dataset.py", line 36, in get_tg_dataset
dataset = load_tg_dataset(dataset_name)
File "P-GNN/dataset.py", line 387, in load_tg_dataset
return nx_to_tg_data(graphs, features, edge_labels)
File "P-GNN/dataset.py", line 134, in nx_to_tg_data
graph.remove_edges_from(graph.selfloop_edges())
AttributeError: 'Graph' object has no attribute 'selfloop_edges'
Could you please help me resolve this error?
Thank you,
Supriya
Hi, @JiaxuanYou
Thanks for sharing your code!
When I run the scripts according to the README.md, some errors occurs:
-----------------Final------------------- 0.73879 0.014555 Loading data... Using only features.. Traceback (most recent call last): File "main.py", line 51, in <module> data_list = get_tg_dataset(args, dataset_name, use_cache=args.cache, remove_feature=args.rm_feature) File "/disk/P-GNN/dataset.py", line 93, in get_tg_dataset infer_link_positive=True if args.task == 'link' else False) File "/disk/P-GNN/utils.py", line 120, in get_link_mask split_edges(data.mask_link_positive, remove_ratio) AttributeError: 'Data' object has no attribute 'mask_link_positive'
It seems that there is something trouble with the input graph data.
Could you help to solve this problem? And give some further introduction for the input data of the project?
Thank you very much!
Waiting for your reply!
Hi Jiaxuan:
Thanks for sharing the code. It is a great project!
I have a question about using x_position as the output. Each dimension of x_position corresponds to an anchor set. As the anchor sets are re-sampled at each epoch, x_position is permuted and the correspondence to anchor sets changed. This will introduce instability to the algorithm? Thanks!
Best Regards,
Qi
Hi Jiaxuan:
Thank you for your source code. It helps me a lot. Recently I'm trying to replicate this paper by tensorflow. However, I encounter some questions when I'm trying to understand your source code.
As detailed in Page 4 "Concretely, the l-th P-GNN layer first samples k random anchor-sets S_i." and algorithm, should I resample anchor-sets at every layer of P-GNN? In your source code, (mode.py line 90 - line 100), anchor-sets are resampled at every epoch.
In model.py, you say:"only pick closest node for message passing". Combining it with your code to undersatnd, I think that you only use feature of the closest node in a anchor set. It's contradictory with this statement "We find that using simple MEAN aggregation function provides good result".
I look forward to your reply.
Hi, I am using P-GNN as a part of my network. It seems that it improves the nodes' features but my code became extremely slow!!
I checked my code and I don't think there is a bug in it. So does P-GNN slow down the performance too much?
If so what is there a reason for that?
My input graph has maximum 200 nodes.
Is there a pretrained P-GNN (Weights) that I can use?
Thank you in advance,
Sahar
Hi @JiaxuanYou, thank you for the great work!
According to the paper, you have applied P-GNNs to multiple prediction tasks, including link prediction and community detection, in the code experiment. I wonder if the code can also be adapted to graph classification task? If so, could you indicate which parts of the code need to be modified accordingly?
Thank you!
ROC AUC may be a better measure than accuracy sometimes, but accuracy is the most common measure in classification tasks, and AUC is usually provided as a supplement.
I'm confused about this choice, which makes the results not comparable to other papers.
Hi, I can not find any definition for augment_adj function in train.py.
Can you help me where it is from to understand your code?
Hi Jiaxuan,
I am having problem of getting your source code running.
I have installed all the necessary dependencies and run the command:
$python main.py --model GCN --layer_num 3 --dataset grid
It gives me the error message:
Do you know how I can get the code running?
I am running it in annaconda environment with python3.7
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.