The code threw an error in the training function.
TypeError: new(): invalid data type 'str’
nb_classes = (list(range(1103)))

class MyDataset(Dataset):

    def __init__(self, df_data, data_dir = './', img_ext='.png', transform=None):
        super().__init__()
        self.df = df_data.values
        self.data_dir = data_dir
        self.img_ext = img_ext
        self.transform = transform

    def __len__(self):
        return len(self.df)
    
    def __getitem__(self, index):
        img_name,label = self.df[index]
        img_path = os.path.join(self.data_dir, img_name+self.img_ext)
        image = cv2.imread(img_path)
        target = torch.zeros(nb_classes)
        target[label] = 1.
        if self.transform is not None:
            image = self.transform(image)
        return image, target

Training function
total_step = len(loader_train)
for epoch in range(num_epochs):
    for i, (images, labels) in enumerate(loader_train):
        images, labels = Variable(images), Variable(labels)

        images = images.to(device)
        labels = labels.to(device)
        
        # Forward pass
        outputs = resNet(images)
        loss = criterion(outputs, labels)
        
        # Backward and optimize
        optimizer.zero_grad()
        loss.backward()
        optimizer.step()
        
        if (i+1) % 100 == 0:
            print ('Epoch [{}/{}], Step [{}/{}], Loss: {:.4f}' 
                   .format(epoch+1, num_epochs, i+1, total_step, loss.item()))