mazeltovlee opened a new issue #20870:
URL: https://github.com/apache/incubator-mxnet/issues/20870


   ## Description
   `mx.sym.Convolution` can still work even when the shape of `mx.sym.Variable` 
is incorrect.
   
   
   ## To Reproduce
   
   
   ### Steps to reproduce
   ```
   import mxnet as mx
   net = mx.symbol.Variable('data')
   net = mx.sym.reshape(data=net, shape=(0, 10, 10, 3))
   net = mx.sym.transpose(data=net, axes=[0,3,1,2])
   
   weight = mx.symbol.Variable("conv2d_1/kernel1", shape=(3, 1e+10, 3, 3), 
stype="default", dtype=np.float32)
   weight = mx.symbol.transpose(data=weight, axes=[0,1,2,3])
   bias = mx.symbol.Variable("conv2d_1/bias1", shape=(3,))
   net = mx.symbol.Convolution(data=net, name="conv2d_1/conv2d3",
                                 kernel=(3, 3), stride=(1, 1), pad=(),
                                 num_filter=3, weight=weight,
                                 dilate=(1,1), bias=bias)
   import numpy as np
   input_shape = (10, 10, 10, 3)
   x = np.random.rand(*input_shape)
   e = net.bind(mx.cpu(), {'data': mx.nd.array(x), "conv2d_1/kernel1": 
mx.nd.array(np.random.rand(3,3,3,3)), "conv2d_1/bias1": 
mx.nd.array(np.random.rand(3,))})
   e.forward()
   ```
   When running the above code, the symbolic model `e` can still output a 
reasonable result even though I have declared the shape of the weight variable 
to be **an unreasonable value: shape=(3, 1e+10, 3, 3)**. It seems that mxnet 
will not refer to the declared shape in `mx.Variable`, but intuitively 
speaking, setting the unreasonable variable shape while model can still run may 
be misleading. 
   
   I am wondering if you can add some shape checks between the declared 
variable shape and the actual bound data shape.


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to