Samples elements randomly from a given list of indices, without replacement. Arguments: indices (list): a list of indices
| 54 | |
| 55 | |
| 56 | class SubsetRandomSampler(Sampler): |
| 57 | """Samples elements randomly from a given list of indices, without replacement. |
| 58 | |
| 59 | Arguments: |
| 60 | indices (list): a list of indices |
| 61 | """ |
| 62 | |
| 63 | def __init__(self, indices): |
| 64 | self.indices = indices |
| 65 | |
| 66 | def __iter__(self): |
| 67 | return (self.indices[i] for i in torch.randperm(len(self.indices))) |
| 68 | |
| 69 | def __len__(self): |
| 70 | return len(self.indices) |
| 71 | |
| 72 | |
| 73 | class WeightedRandomSampler(Sampler): |
nothing calls this directly
no outgoing calls
no test coverage detected