Browse Source

!711 Address first epoch always shuffle with same seed init of random sampler

Merge pull request !711 from ZiruiWu/mindspore_master_only
tags/v0.3.0-alpha
mindspore-ci-bot Gitee 5 years ago
parent
commit
c47ef8ee4e
2 changed files with 2 additions and 2 deletions
  1. +1
    -1
      mindspore/ccsrc/dataset/engine/datasetops/source/sampler/random_sampler.cc
  2. +1
    -1
      tests/ut/python/dataset/test_datasets_celeba.py

+ 1
- 1
mindspore/ccsrc/dataset/engine/datasetops/source/sampler/random_sampler.cc View File

@@ -53,6 +53,7 @@ Status RandomSampler::InitSampler() {
num_samples_ = (user_num_samples_ < num_samples_) ? user_num_samples_ : num_samples_;
CHECK_FAIL_RETURN_UNEXPECTED(num_samples_ > 0 && num_rows_ > 0, "both num_samples & num_rows need to be positive");
samples_per_buffer_ = samples_per_buffer_ > num_samples_ ? num_samples_ : samples_per_buffer_;
rnd_.seed(seed_++);
if (replacement_ == false) {
shuffled_ids_.reserve(num_rows_);
for (int64_t i = 0; i < num_rows_; i++) {
@@ -62,7 +63,6 @@ Status RandomSampler::InitSampler() {
} else {
dist = std::make_unique<std::uniform_int_distribution<int64_t>>(0, num_rows_ - 1);
}
rnd_.seed(seed_++);
return Status::OK();
}



+ 1
- 1
tests/ut/python/dataset/test_datasets_celeba.py View File

@@ -20,7 +20,7 @@ DATA_DIR = "../data/dataset/testCelebAData/"


def test_celeba_dataset_label():
data = ds.CelebADataset(DATA_DIR, decode=True)
data = ds.CelebADataset(DATA_DIR, decode=True, shuffle=False)
expect_labels = [
[0, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 1, 1, 0, 1, 0, 0, 1, 0, 0, 1, 0, 0, 0, 1, 1, 0, 1, 0, 1,
0, 0, 1],


Loading…
Cancel
Save