You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/11/21 03:20:33 UTC

[GitHub] anirudh2290 commented on a change in pull request #13328: adding test for softmax operator for large negative inputs

anirudh2290 commented on a change in pull request #13328: adding test for softmax operator for large negative inputs
URL: https://github.com/apache/incubator-mxnet/pull/13328#discussion_r235242621
 
 

 ##########
 File path: tests/python/unittest/test_operator.py
 ##########
 @@ -4449,6 +4449,20 @@ def test_log_softmax():
             check_symbolic_forward(sym, [data], [np.log(np_softmax(data, axis=axis)+1e-20)])
             check_numeric_gradient(sym, [data], rtol=0.05, atol=1e-3)
 
+def test_softmax_with_large_inputs():
+    def softmax_forward(input_data, true_output):
+        data = mx.sym.Variable('data')
+        out1 = data.softmax(axis=1)
+        exec1 = out1.bind(mx.cpu(), args={'data': input_data})
+        exec1.forward()[0].wait_to_read()
+        ndarr = exec1.outputs[0][0][0][0]
+        nparr = ndarr.asnumpy()
+        assert np.array_equal(nparr, true_output)
 
 Review comment:
   can we use assert_almost_equal in test_utils.

----------------------------------------------------------------
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:
users@infra.apache.org


With regards,
Apache Git Services