TypeError: zip argument #3 must support iteration

Hello I am getting the below error and its running for 2 batches and throwing this error.

Thanks

Could you add an assert statement in the else condition in your __getitem__?
Maybe the condition is not met and you return nothing, which might yield this error.

Thanks but assert what?.

I would just add a dummy assert statement or raise an exception, so that the code crashes:

assert False, "empty batch"
raise RuntimeError("empty batch")

Got the below error.Does that mean the next batch of 64 images aren’t present in folder.
AssertionError Traceback (most recent call last)
in
2 res.train()
3 running_loss=0
----> 4 for i,(data,target) in enumerate(train_load):
5
6 print(i,data.shape,target.shape)

/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py in next(self)
558 if self.num_workers == 0: # same-process loading
559 indices = next(self.sample_iter) # may raise StopIteration
→ 560 batch = self.collate_fn([self.dataset[i] for i in indices])
561 if self.pin_memory:
562 batch = _utils.pin_memory.pin_memory_batch(batch)

/anaconda3/lib/python3.6/site-packages/torch/utils/data/dataloader.py in (.0)
558 if self.num_workers == 0: # same-process loading
559 indices = next(self.sample_iter) # may raise StopIteration
→ 560 batch = self.collate_fn([self.dataset[i] for i in indices])
561 if self.pin_memory:
562 batch = _utils.pin_memory.pin_memory_batch(batch)

in getitem(self, idx)
19 self.cj.append(img)
20 #assert(path.exists(img)),“wronggg”
—> 21 assert False, “empty batch”
22 raise RuntimeError(“empty batch”)
23

AssertionError: empty batc

Yes, apparently neither the file is “open/closed” (not sure what this entry means) nor the path can be found.
Add the img to the exception/assert so that you’ll see which path is wrong and can fix it.

Thanks.But I tried to add to list and see if 64 images aren’t in proper format.But I get the following now.Can you please explain what does that mean.Thanks

It looks like more than a single path cannot be found, so that the length of the list grows.
Can you print this list after the code crashed using print(dataset.cj), where dataset refers to the instance of your current Dataset.

PS: It’s better to post the code directly by wrapping it in three backticks ```, as this will e.g. allow to search for the code :wink:

What was the solution for this?

Could you give more details which solution you mean?
My suggestion to add assert statements was to debug the issue in the original post.