Too many values to unpack

Hello all,

I’m currently studying aws MLE and we should make a project about image classifications database dog breeds.

after wrote the training script, every time i run the code it raises value error Too many values to unpack

Failure reason
AlgorithmError: ExecuteUserScriptError: Command "/opt/conda/bin/python3.6 hpo.py --batch-size 32 --lr 0.003409797631466478" Downloading: "https://download.pytorch.org/models/resnet18-5c106cde.pth" to /root/.cache/torch/hub/checkpoints/resnet18-5c106cde.pth 0%| | 0.00/44.7M [00:00<?, ?B/s] 43%|████▎ | 19.2M/44.7M [00:00<00:00, 201MB/s] 87%|████████▋ | 39.0M/44.7M [00:00<00:00, 205MB/s] 100%|██████████| 44.7M/44.7M [00:00<00:00, 206MB/s] Traceback (most recent call last): File "hpo.py", line 194, in <module> main(args) File "hpo.py", line 143, in main train(model, train_loader, criterion, optimizer, epoch, device) File "hpo.py", line 57, in train for data, target in train_loader: ValueError: too many values to unpack (expected 2), exit code: 1

here is my code

if anyone could help i will be very appreciated

thanks in advance

Check what your train_loader returns e.g. via print(next(iter(train_loader))) and make sure you are receiving two objects. If that’s not the cast check why the Dataset might not return your expected tensors.

Thanks a lot for your help sir, I will try it, and hope that I will figure it out.