mshadow
mshadow copied to clipboard
Random<>::SampleUniform() has inconsistant behaviours on CPU, GPU and docs
According to docs, Random<>::SampleUniform(&dst, a, b)
should generate random samples uniformly distributed in [a, b)
.
However, when DType = float
, std::uniform_real_distribution
, which is used internally in SampleUniform
for CPU, might accidentally return b
. This is an issue in most stdlib implementations. See LWG#2524, GCC#63176, LLVM#18767.
On GPU, curandGenerateUniform()
is used, but it actually produces samples in (0, 1]
according its documentation:
Results are 32-bit floating point values between 0.0f and 1.0f, excluding 0.0f and including 1.0f.
which results in (a, b]
for SampleUniform()
. The same issue affects double
version as well.
This code base has been donated to the Apache MXNet project per #373, and repo is deprecated. Future development and issue tracking should continue in Apache MXNet.