Problems loading data for to pytorch,please

from libtiff import TIFF
import torch

class ISBIdata(
“”“to load data”""
def init(self, dataPath):
super(ISBIdata, self).init()

    data_volume =
    volume = []
    for img in data_volume.iter_images():

    # print(len(volume))
    self.volume = volume

def __getitem__(self, index):
    return self.volume[index]

def __len__(self):
    return len(self.volume)

def main():
train_data = ISBIdata(’/home/mellow/Projects/U-Net/train-volume.tif’)

if name == ‘main’:

here’s my code,but I got ‘AttributeErro’:
AttributeError: module ‘torch.utils’ has no attribute ‘data’

I can make sure of the installation of pytorch, but I don’t know what’s wrong of my code. Or am using a wrong way of loading data?


I am assuming you are dealing with a semantic segmentation task. And I think this thread can really help you!

1 Like

‘torch.utils’ is not a module, it’s a package. You can import the class-“Dataset” from the module-“data” in the package-“torch.utils”

from import Dataset
class ISBIdata(Dataset):

thank u.
I tyied to import ‘’, as I could call in my class.
problem solved~

thank u for sharing.