示例#1
0
    def __init__(
        self,
        sampler,
        num_replicas: Optional[int] = None,
        rank: Optional[int] = None,
        shuffle: bool = True,
    ):
        """

        Args:
            sampler: Sampler used for subsampling
            num_replicas (int, optional): Number of processes participating in
              distributed training
            rank (int, optional): Rank of the current process
              within ``num_replicas``
            shuffle (bool, optional): If true (default),
              sampler will shuffle the indices
        """
        super(DistributedSamplerWrapper, self).__init__(
            DatasetFromSampler(sampler),
            num_replicas=num_replicas,
            rank=rank,
            shuffle=shuffle,
        )
        self.sampler = sampler
示例#2
0
 def __init__(self, sampler, num_replicas=None, rank=None, shuffle=True):
     super(DistributedSamplerWrapper,
           self).__init__(DatasetFromSampler(sampler),
                          num_replicas=num_replicas,
                          rank=rank,
                          shuffle=shuffle)
     self.sampler = sampler
示例#3
0
 def __iter__(self):
     self.dataset = DatasetFromSampler(self.sampler)
     indexes_of_indexes = super().__iter__()
     subsampler_indexes = self.dataset
     return iter(itemgetter(*indexes_of_indexes)(subsampler_indexes))
示例#4
0
 def __iter__(self):
     """@TODO: Docs. Contribution is welcome."""
     self.dataset = DatasetFromSampler(self.sampler)
     indexes_of_indexes = super().__iter__()
     subsampler_indexes = self.dataset
     return iter(itemgetter(*indexes_of_indexes)(subsampler_indexes))