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'
import torch
import torch.utils.data

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

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?

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