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

MxNet allow to use same name #9890

Closed
Caenorst opened this issue Feb 26, 2018 · 2 comments
Closed

MxNet allow to use same name #9890

Caenorst opened this issue Feb 26, 2018 · 2 comments

Comments

@Caenorst
Copy link
Contributor

Caenorst commented Feb 26, 2018

Description

MxNet allow me to reuse a name of a symbol without returning an error, it eventually leads to a cyclic graph in the visualization.

It should prevent the user to be able to reuse the same name unless the user want specifically to reuse the same variable (with an argument), instead of advising them to not reuse the same name (#2036)

Environment info (Required)

on Intel Core i7-5820K
with pip install mxnet

Error Message:

There is no error message, and that's the problem.

Minimum reproducible example

a=mx.sym.Variable('u')
b=mx.sym.relu(a,'v')
c=mx.sym.log(b,'u')
mx.viz.plot_network(c)

in1 = mx.nd.random.uniform(0.001,5,shape=[2,2])
ex = c.bind(ctx=mx.cpu(), args={'u' : in1})
print ex.forward()
print ex.output_dict
print ex.arg_dict
print in1

return a cyclic graph (u => v => u) and:

[[-2.28207898  0.61076486]
 [ 1.42630005  1.56565714]]
<NDArray 2x2 @cpu(0)>]
{'u_output': 
[[-2.28207898  0.61076486]
 [ 1.42630005  1.56565714]]
<NDArray 2x2 @cpu(0)>}
{'u': 
[[ 0.10207178  1.84183955]
 [ 4.16326666  4.78581858]]
<NDArray 2x2 @cpu(0)>}

[[ 0.10207178  1.84183955]
 [ 4.16326666  4.78581858]]
<NDArray 2x2 @cpu(0)>

Which shows that u is BOTH the input variable and the log function.

@roywei
Copy link
Member

roywei commented Apr 6, 2018

Hi @Caenorst
I think this is not a bug, users may want to create two variables with same name and use in different graphs as mentioned in your reference issue. We should allow to use same name

This your case, the output seems correct, if modify your code to not use the same name:
c=mx.sym.log(b,'x')
it will print the same output as your code snippet.
The only difference is the cycle in graph visualization, which dictates user has used repeated name. I added this PR to prevent confusion

@roywei
Copy link
Member

roywei commented Jul 2, 2018

#10429 should fix this.
@sandeep-krishnamurthy could you help to close this issue?
Thanks

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

No branches or pull requests

4 participants