Dataset Inheritance does not require super?

I have seen in the Dataset pytorch tutorial (https://pytorch.org/tutorials/beginner/data_loading_tutorial.html) that super is not called when inheriting from Dataset.

Does anyone know why this has not been done?

torch.utils.data.Dataset doesn’t define its own __init__ so by calling super().__init__() you are not performing any meaningful actions. In comparison, calling super().__init__() when subclassing torch.nn.Module is required to initialize the internal data structures for storing buffers, modules, etc.

2 Likes

So when extending the Dataset class we should not use super().__init__() in our init function of the new class that extends Dataset?

You can, but it’s not necessary. The end-result is the same.