(self, start, end, num_examples, shuffle)
| 90 | self._checkpoint = None |
| 91 | |
| 92 | def _get_worklist(self, start, end, num_examples, shuffle): |
| 93 | if end - start < num_examples: |
| 94 | logger.warn( |
| 95 | f"Attempting to attack {num_examples} samples when only {end - start} are available." |
| 96 | ) |
| 97 | candidates = list(range(start, end)) |
| 98 | if shuffle: |
| 99 | random.shuffle(candidates) |
| 100 | worklist = collections.deque(candidates[:num_examples]) |
| 101 | candidates = collections.deque(candidates[num_examples:]) |
| 102 | assert (len(worklist) + len(candidates)) == (end - start) |
| 103 | return worklist, candidates |
| 104 | |
| 105 | def _attack(self): |
| 106 | """Internal method that carries out attack. |
no test coverage detected