gilbertfrancois commented on pull request #19344:
URL: https://github.com/apache/incubator-mxnet/pull/19344#issuecomment-707659832


   I made a small test to show its new behaviour. Note that the test is done on 
gpu, because on cpu, only 1D or 2D Deconvolution is supported.
   
   ```
   import mxnet as mx
   
   
   ctx = mx.gpu(0)
   
   x_1d = mx.nd.random.randn(1, 1, 8, ctx=ctx)
   x_2d = mx.nd.random.randn(1, 1, 8, 8, ctx=ctx)
   x_3d = mx.nd.random.randn(1, 1, 8, 8, 8, ctx=ctx)
   
   conv = mx.gluon.nn.Conv1D(in_channels=1, channels=2, kernel_size=3, 
strides=1)
   conv.initialize(ctx=ctx)
   y_1d = conv(x_1d)
   mx.nd.waitall()
   print(conv)
   assert x_1d.shape[1] == 1
   assert y_1d.shape[1] == 2
   conv_t = mx.gluon.nn.Conv1DTranspose(in_channels=1, channels=2, 
kernel_size=3, strides=1)
   conv_t.initialize(ctx=ctx)
   y_1d = conv_t(x_1d)
   mx.nd.waitall()
   print(conv_t)
   assert x_1d.shape[1] == 1
   assert y_1d.shape[1] == 2
   
   conv = mx.gluon.nn.Conv2D(in_channels=1, channels=2, kernel_size=3, 
strides=1)
   conv.initialize(ctx=ctx)
   y_2d = conv(x_2d)
   mx.nd.waitall()
   print(conv)
   assert x_2d.shape[1] == 1
   assert y_2d.shape[1] == 2
   assert "1 -> 2" in conv.__repr__()
   conv_t = mx.gluon.nn.Conv2DTranspose(in_channels=1, channels=2, 
kernel_size=3, strides=1)
   conv_t.initialize(ctx=ctx)
   y_2d = conv_t(x_2d)
   mx.nd.waitall()
   print(conv_t)
   assert x_2d.shape[1] == 1
   assert y_2d.shape[1] == 2
   assert "1 -> 2" in conv_t.__repr__()
   
   conv = mx.gluon.nn.Conv3D(in_channels=1, channels=2, kernel_size=3, 
strides=1)
   conv.initialize(ctx=ctx)
   y_3d = conv(x_3d)
   mx.nd.waitall()
   assert x_3d.shape[1] == 1
   assert y_3d.shape[1] == 2
   print(conv)
   conv_t = mx.gluon.nn.Conv3DTranspose(in_channels=1, channels=2, 
kernel_size=3, strides=1)
   conv_t.initialize(ctx=ctx)
   y_3d = conv_t(x_3d)
   mx.nd.waitall()
   assert x_3d.shape[1] == 1
   assert y_3d.shape[1] == 2
   print(conv_t)
   ```


----------------------------------------------------------------
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.

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


Reply via email to