are sampled based on the weights specified on creation of the
UnigramCandidateSampler.
flat_shape = functools.reduce(operator.mul, self._shape)
idx = F.random.uniform(low=0, high=self.N, shape=flat_shape,
dtype="float64").floor()
prob = F.gather_nd(prob, idx.reshape((1, -1)))
alias = F.gather_nd(alias, idx.reshape((1, -1)))
After Change
are sampled based on the weights specified on creation of the
UnigramCandidateSampler.
candidates_flat = candidates_like.reshape((-1, )).astype("float64")
idx = F.random.uniform_like(candidates_flat, low=0, high=self.N).floor()
prob = F.gather_nd(prob, idx.reshape((1, -1)))
alias = F.gather_nd(alias, idx.reshape((1, -1)))
where = F.random.uniform_like(candidates_flat) < prob