-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
List node features can not be sliced with subgraph #6162
Comments
Thanks for the issue. |
Hi, I think I have a similar problem. Each node in my graph has a whole point cloud associated with it. So, for example, one graph would look like this:
Where
The point_cloud attribute still contains all point clouds in my graph instead of containing only the point clouds for the sampled subgraph. I looked into the It would be very helpful to also have vanilla lists be considered or have a special data structure for fields in a |
I think this is a good suggestion - we currently don't do this. Let me see what I can do. |
Thanks for the quick response. As this feature is also somewhat crucial to my own research, I would be glad to help with implementing this once it's decided whether you want to go for a custom data structure, a vanilla list, or something else. |
I think all we need to do is filter out the elements of a list whenever we encounter a list with length being equal to the number of nodes, e.g., here. |
I experimented a bit more with my dataset and I'm preparing a pull request for this. However, I think to fully support list fields and get the behavior that I would expect, I would also need to make adjustments to |
Do you think so? I think they should be already working as expected (as they don't do any filtering). |
Only adjusting the filtering works if the dataset consists of just one graph, e.g:
If I adjust the filtering in
However, the dataset that I am working with consists of multiple such graphs. I am using
The I know that passing this big |
I'm testing if isinstance(value, list):
out[key] = [value[i] for i in node_idx] in all of these places does not seem very elegant. I suppose However, if isinstance(item, list) and len(item) == N:
data[key] = item[start:start+length] Essentially we would have to add |
Yes, this is tricky. For To support this more elegantly, I am afraid we need to add some kind of "index_select" interface that also supports lists. Extending |
Yes, I also think some kind of interface that supports lists would be a better option. I made some quick and dirty adjustments in a few places in my own copy of PyG in order to run my experiments and it's working at the moment, but I only adjusted the places that I currently need, such as the mentioned |
Personally, I would prefer to just start with filtering, and modify the places accordingly, i.e., def filter_node_attributes(data, node_index_or_mask):
... which is then called in each of these functions. WDYT? |
Sounds good to me. I'll see what I can do and prepare a pull request. |
This adds a unified interface to perform filtering of node attributes in order to support attributes of type `list` inside `Data` objects. For now, this is only used in `Data.subgraph`, `ClusterData` and `ClusterLoader`, but should probably be extended in the future, as discussed in issue #6162. --------- Co-authored-by: rusty1s <matthias.fey@tu-dortmund.de>
How to pass subgraph Data as a node feature into main graph Data?
test_data=Data(edge_index=edge_index,pos=torch.tensor(np.array(pos)), graph=subgraphList)
subgraphList is as follows:
The text was updated successfully, but these errors were encountered: