Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

mx.symbol.numpy._Symbol.__deepcopy__ logic error #18685

Closed
leezu opened this issue Jul 10, 2020 · 1 comment · Fixed by #18686
Closed

mx.symbol.numpy._Symbol.__deepcopy__ logic error #18685

leezu opened this issue Jul 10, 2020 · 1 comment · Fixed by #18686

Comments

@leezu
Copy link
Contributor

leezu commented Jul 10, 2020

mx.symbol.numpy._Symbol.__deepcopy__ performs shallow copy instead of deep copy like mx.symbol.Symbol.__deepcopy__ .

Problem:

[ins] In [1]: import mxnet as mx

[ins] In [2]: import copy

[ins] In [3]: v = mx.sym.Variable('a').as_np_ndarray()

[ins] In [4]: b = copy.copy(v)

[ins] In [5]: b._set_attr(name='b')

[ins] In [6]: v
Out[6]: <_Symbol b>

[ins] In [7]: b
Out[7]: <_Symbol b>

Expected:

[ins] In [1]: import mxnet as mx

[ins] In [2]: import copy

[ins] In [3]: v = mx.sym.Variable('a').as_np_ndarray()

[ins] In [4]: b = copy.copy(v)

[ins] In [5]: b._set_attr(name='b')

[ins] In [6]: v
Out[6]: <_Symbol a>

[ins] In [7]: b
Out[7]: <_Symbol b>
@wkcn
Copy link
Member

wkcn commented Jul 10, 2020

Agree the expected result, which is consistent with mx.nd:

import mxnet as mx
import copy

v = mx.nd.array([1,2,3]).as_np_ndarray()
b = copy.copy(v)
b[0] = 10
print(b) # [10. 2. 3.]
print(v) # [1. 2. 3.]

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants