diff --git a/src/operator/tensor/elemwise_binary_scalar_op.h b/src/operator/tensor/elemwise_binary_scalar_op.h index a6fdf1e7572d..13d147bc698c 100644 --- a/src/operator/tensor/elemwise_binary_scalar_op.h +++ b/src/operator/tensor/elemwise_binary_scalar_op.h @@ -26,6 +26,7 @@ #define MXNET_OPERATOR_TENSOR_ELEMWISE_BINARY_SCALAR_OP_H_ #include +#include #include #include #include @@ -50,7 +51,7 @@ struct NumpyBinaryScalarParam : public dmlc::Parameter { void SetAttrDict(std::unordered_map* dict) { std::ostringstream scalar_s, is_int_s; - scalar_s << scalar; + scalar_s << std::setprecision(std::numeric_limits::max_digits10) << scalar; is_int_s << is_int; (*dict)["scalar"] = scalar_s.str(); (*dict)["is_int"] = is_int_s.str(); diff --git a/tests/python/unittest/test_numpy_op.py b/tests/python/unittest/test_numpy_op.py index 1abbeba4fcf2..053fa9d64daa 100644 --- a/tests/python/unittest/test_numpy_op.py +++ b/tests/python/unittest/test_numpy_op.py @@ -3458,9 +3458,9 @@ def forward(self, a): @use_np def test_npx_activation_log_sigmoid(): def np_log_sigmoid(x): - return _np.log(_np.divide(1.0, (1.0 + _np.exp(-x)))) + return onp.log(onp.divide(1.0, (1.0 + onp.exp(-x)))) def np_log_sigmoid_grad(x): - return _np.divide(1.0, _np.add(1.0, _np.exp(x))) + return onp.divide(1.0, onp.add(1.0, onp.exp(x))) class TestLogSigmoid(HybridBlock): def __init__(self):