Hi all,
@MONAI
I am using MONAI Compose and Dataset to transform my image dataset and train and validate a neural network… However, I am getting the following error…
in train
for batch_idx, (data, target) in enumerate(dataloader):
ValueError: too many values to unpack (expected 2)
here is my code:
train_ds = Dataset(data=train_files, transform=train_transforms)
    dataloader_train = torch.utils.data.DataLoader(
        train_ds,
        batch_size=2, shuffle=True, num_workers=4, pin_memory=True
    )

val_ds = Dataset(data=val_files, transform=val_transforms)
    dataloader_val = torch.utils.data.DataLoader(
        val_ds, batch_size=1, shuffle=False, num_workers=4, pin_memory=True
    )


def train(model, dataloader, optimizer, loss_func):
    model.train()
    total_loss = 0
    for batch_idx, (data, target) in enumerate(dataloader):
        data, target = data.cuda(), target.cuda()
        optimizer.zero_grad()
        output = model(data)
        loss = loss_func(output, target)
        loss.backward()
        optimizer.step()

        total_loss += loss.item()

    return total_loss/len(dataloader)

I would greatly appreciate any help with this…Spent so much time…no success !
Thank you,