AttributeError: module 'torch.utils' has no attribute 'data'

This runtime error is resulted from

import torch
torch.utils.data.DataLoader

->

AttributeError: module 'torch.utils' has no attribute 'data'
3 Likes
import torch
import torch.utils.data
16 Likes

Might be a bit off topic, but do we ned to do this?

1 Like

Thanks, I ran into the same problem.

I suppose torch/utils/__init__.py does not contain an import data or something along these lines.

@smth May I know the reason why do we have to import torch.utils.data instead of using torch.utils.data.DataLoader directly please?

3 Likes

You can do that as well. In that case just do like this:

import torch.utils.data.DataLoader as <something>

You have to fill something with whatever word you like