Deep copy error on modules implementing MessagePassing
See original GitHub issue🐛 Bug
Since pytorch_geometric version 1.4 modules derived from the class MessagePassing
cannot be deep copied (no issues with older versions).
To Reproduce
Just run the following lines (same issue occurring with any other layer derived from MessagePassing
)
import copy
import torch_geometric
gconv = torch_geometric.nn.GCNConv(1,1)
copy.deepcopy(gconv)
which produce:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/opt/conda/lib/python3.6/copy.py", line 180, in deepcopy
y = _reconstruct(x, memo, *rv)
File "/opt/conda/lib/python3.6/copy.py", line 280, in _reconstruct
state = deepcopy(state, memo)
File "/opt/conda/lib/python3.6/copy.py", line 150, in deepcopy
y = copier(x, memo)
File "/opt/conda/lib/python3.6/copy.py", line 240, in _deepcopy_dict
y[deepcopy(key, memo)] = deepcopy(value, memo)
File "/opt/conda/lib/python3.6/copy.py", line 169, in deepcopy
rv = reductor(4)
TypeError: can't pickle mappingproxy objects
Expected behavior
Should have produced a new deep copy of the object instead.
Environment
Nvidia DGX station
Virtual environment with:
- torch 1.4
- torch_geometric 1.4.1
Additional context
A deep copy is necessary in order to copy models or parts of models whose weighs are later altered.
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Deep copy error on modules implementing MessagePassing
Bug Since pytorch_geometric version 1.4 modules derived from the class MessagePassing cannot be deep copied (no issues with older versions).
Read more >copy.deepcopy raises TypeError on objects with self- ...
one problem is that deepcopy and copy have no way of knowing which arguments to pass to __new__ , therefore they only work...
Read more >Shallow and deep copy operations
This module provides generic shallow and deep copy operations (explained below). ... The latter is called to implement the deep copy operation; it...
Read more >copy – Duplicate objects - Python Module of the Week
Any member attributes that need to be deep-copied should be passed to copy.deepcopy(), along with the memo dictionary, to control for recursion (see...
Read more >OMNeT++ - Simulation Manual - Index of - omnetpp.org
The depth of module nesting is not limited. Modules communicate through message passing, where messages may carry arbitrary data structures. Modules can pass ......
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
Fixed with
1.4.2
.Awesome!! 😄