ChaiBapchya commented on a change in pull request #12558: [MXNET-952] added a
line to check for kernel size and unittest for the same
URL: https://github.com/apache/incubator-mxnet/pull/12558#discussion_r217785257
##########
File path: tests/python/unittest/test_operator.py
##########
@@ -6913,6 +6913,28 @@ def test_invalid_depth_dim():
test_invalid_block_size()
test_invalid_depth_dim()
+@with_seed()
+def test_correlation_kernel_size():
+ import numpy as np
+ import mxnet as mx
+
+ # Network
+ data1 = mx.symbol.Variable('data1')
+ cor = mx.sym.Correlation(data1=data1, data2=data1, kernel_size=28,
stride1=1, stride2=1, pad_size=0, max_displacement=0)
+ loss = mx.sym.MakeLoss(cor, normalization='batch')
+ group = mx.symbol.Group([mx.sym.BlockGrad(cor), loss])
+
+ # Data
+ datashape = (1, 1, 28, 28) # like mnist
+ data = np.random.rand(1, 1, 28, 28)
+
+ #Bind, execute, get computed correlation
+ executor = group.simple_bind(ctx=mx.cpu(), data1=datashape)
+ outs = executor.forward(is_train=True, data1=data)
+ cor = executor.outputs[0]
+ grad1 = executor.outputs[1]
+ print(cor)
Review comment:
I am not testing the regular case (kernel_size being odd).
Exception is raised when it is even. I have tested for even number
(kernel_size=28).
But yes, here the aim is only to test if error is raised or not, hence
removing the print statement since not needed. Only function to be tested is
the `forward`
Hence keeping at that.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
With regards,
Apache Git Services