Skip to content

Make VisionDataset generic following DatasetΒ #9282

@Glinte

Description

@Glinte

πŸš€ The feature

torch.utils.data.datasets.Dataset is already generic wrt the item type, so it would be nice to expose the type parameter to users

_T_co = TypeVar("_T_co", covariant=True)

class Dataset(Generic[_T_co]):
    def __getitem__(self, index) -> _T_co:
        raise NotImplementedError("Subclasses of Dataset should implement __getitem__.")

but

class VisionDataset(data.Dataset):
    ...

Motivation, pitch

I am making a subclass of VisionDataset and I noticed DataLoader(VisionDataset(...)) doesn't have generic information.

Alternatives

No response

Additional context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions