提交 026ed2b8 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!4638 fix core when use weighted_random_sampler

Merge pull request !4638 from yanghaitao/yht_fix_weighted_sampler
......@@ -44,6 +44,13 @@ Status WeightedRandomSampler::InitSampler() {
}
CHECK_FAIL_RETURN_UNEXPECTED(num_rows_ > 0 && num_samples_, "num_samples & num_rows need to be positive");
CHECK_FAIL_RETURN_UNEXPECTED(samples_per_buffer_ > 0, "samples_per_buffer<=0\n");
if (weights_.size() > static_cast<size_t>(num_rows_)) {
return Status(StatusCode::kUnexpectedError, __LINE__, __FILE__,
"number of samples weights is more than num of rows. Might generate id out of bound OR other errors");
}
if (!replacement_ && (weights_.size() < static_cast<size_t>(num_samples_))) {
RETURN_STATUS_UNEXPECTED("Without replacement, sample weights less than numSamples");
}
// Initialize random generator with seed from config manager
rand_gen_.seed(GetSeed());
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册