pytorch/torch/utils/data/sampler.pyi
Jon Malmaud 0565141728 Type annotations for util.data. (#18963)
Summary:
I haven't had a chance to rigorously try these out yet so don't merge yet.
Closes #18725.
Pull Request resolved: https://github.com/pytorch/pytorch/pull/18963

Differential Revision: D14832897

Pulled By: ezyang

fbshipit-source-id: 4780e7a34126bc66ddbfd9d808dfc9e0edd77e68
2019-04-08 09:52:53 -07:00

25 lines
886 B
Python

from typing import Iterator, Optional, Sequence, List, TypeVar, Generic, Sized
T_co = TypeVar('T_co', covariant=True)
class Sampler(Generic[T_co]):
def __init__(self, data_source: Sized) -> None: ...
def __iter__(self) -> Iterator[T_co]: ...
def __len__(self) -> int: ...
class SequentialSampler(Sampler[int]):
pass
class RandomSampler(Sampler[int]):
num_samples: int
def __init__(self, data_source: Sized, replacement: bool=..., num_samples: Optional[int]=...) -> None: ...
class SubsetRandomSampler(Sampler[int]):
def __init__(self, indices: Sequence[int]) -> None: ...
class WeightedRandomSampler(Sampler[int]):
def __init__(self, weights: Sequence[float], num_samples: int, replacement: bool=...) -> None: ...
class BatchSampler(Sampler[List[int]]):
def __init__(self, sampler: Sampler[int], batch_size: int, drop_last: bool) -> None: ...