How to copy a `torch_geometric.data.Data` object?
See original GitHub issue❓ Questions & Help
I like the torch_geometric.data.Data
object a lot, especially in combination with all the other neat stuff and the general apply
function. One thing I am missing and currently have a stupid work-around for is the copying of such a data object.
E.g. the apply function does generate new torch.Tensor
objects but overwrites the attributes of the existing Data
object. So when I pass a Data
object into a function and want to process the data without affecting the input object, I need to make a copy of the Data
object.
Currently I am doing this via data = torch_geometric.data.Data.from_dict(data.to_dict())
.
My question is, is there a better way of doing this or a reason why there does not exist a copy method?
Thanks for your input on this 😃
Issue Analytics
- State:
- Created 3 years ago
- Comments:9 (5 by maintainers)
Top Results From Across the Web
How to copy a torch_geometric.data.Data object? #2050
There is a Data.clone() to deep-copy a data object. Alternatively, copy.copy(data) and copy.deepcopy(data) ...
Read more >torch_geometric.data — pytorch_geometric documentation
A data object describing a heterogeneous graph, holding multiple node and/or ... if edge indices edge_index are sorted and do not contain duplicate...
Read more >Data handling in PyTorch Geometric (Part 1) - YouTube
How is a graph represented in Pytorch Geometric? How one can handle collections of data ? This is the first of two tutorials...
Read more >Graphein Protein Structure Dataloaders
The data object will be transformed before every access. ) Copy to clipboard. [6]:
Read more >How to load in graph from networkx into PyTorch geometric ...
Then you name your input features x and your labels/ground truth y . The splitting of the data into train and test is...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Hi @rusty1s
Thanks for your answer, so If I install now PyG using
It should be ok, right?
There is a
Data.clone()
to deep-copy adata
object. Alternatively,copy.copy(data)
andcopy.deepcopy(data)
should work just fine.