| 27 | super(BaseDataLoader, self).__init__(sampler=self.sampler, **self.init_kwargs) |
| 28 | |
| 29 | def _split_sampler(self, split): |
| 30 | if split == 0.0: |
| 31 | return None, None |
| 32 | |
| 33 | idx_full = np.arange(self.n_samples) |
| 34 | |
| 35 | np.random.seed(1) |
| 36 | np.random.shuffle(idx_full) |
| 37 | |
| 38 | len_valid = int(self.n_samples * split) |
| 39 | |
| 40 | valid_idx = idx_full[0:len_valid] |
| 41 | train_idx = np.delete(idx_full, np.arange(0, len_valid)) |
| 42 | |
| 43 | train_sampler = SubsetRandomSampler(train_idx) |
| 44 | valid_sampler = SubsetRandomSampler(valid_idx) |
| 45 | |
| 46 | # turn off shuffle option which is mutually exclusive with sampler |
| 47 | self.shuffle = False |
| 48 | self.n_samples = len(train_idx) |
| 49 | |
| 50 | return train_sampler, valid_sampler |
| 51 | |
| 52 | def split_validation(self): |
| 53 | if self.valid_sampler is None: |