AttributeError: module ‘torch.utils’ has no attribute ‘data’ solution

Execution environment

When I try to use DataLoader with Pytorch, I get the following error

Program executed


import torch

torch.utils.data.DataLoader(
    dataset = dataset,
    batch_size = 100,
    shuffle = True,
    num_workers = 0)

Error statement


AttributeError: module ‘torch.utils’ has no attribute ‘data’

solution

The solution is to use ʻimport torch.utils.data instead of ʻimport torch.

Recommended Posts

AttributeError: module ‘torch.utils’ has no attribute ‘data’ solution
[Dlib] Attribute Error: module'dlib' has no attribute ...
[Python] Attribute Error:'list' object has no attribute'replace'
[Wandb] Attribute Error: module'wandb' has no attribute'init'
Solution for "Import Error: No module named requests"
AttributeError: module'urllib' has no attribute'request' error in urllib.request
How to deal with module'tensorflow' has no attribute'〇〇'
Solution when module'XXX' has no attribute'XXX' in Python
Django "Query Set, Object has no attribute'foo'" solution
AttributeError: I was addicted to'module' object has no attribute'MyTestCase'
AttributeError: The story of solving module'tensorflow' has no attribute'log'.