mxnet icon indicating copy to clipboard operation
mxnet copied to clipboard

"ValueError: too many values to unpack"

Open jimxinbo opened this issue 11 years ago • 3 comments

I am getting "ValueError: too many values to unpack" when running "for _, label in test_dataiter:" in cifar-recipe.ipynb. I am using Python 2.7. I am not familiar with the MXDataIter, it seems "for _, label in test_dataiter[:2]:" will not fix it. Is there any quick way around? Thank you very much.

jimxinbo avatar Nov 25 '15 04:11 jimxinbo

could you try example/image-classification/train_cifar10.py? The examples under notebooks might be out dated.

piiswrong avatar Nov 25 '15 04:11 piiswrong

Thanks piiswrong!

I can run example/cifar10/cifar10 without any problem. In the new version example/image-classification/train_cifar10.py is not that much different.

The problem is when I use the notebook example, where there is extra code for testing. During testing, "for _, label in test_dataiter:" seems to be unpacking from an iterator (defined as MXDataIter).

Anyway, the sad story is that I have to use mxnet on windows for now and I am using the pre-build version from https://github.com/dmlc/mxnet/releases as recommended. Maybe the pre-build version is obsolete. If there is really no other way around, say, the behavior of the iterator class totally changed in the new version, I will bother to compile the latest version from scratch. But it will very be helpful to me if you can let me know how you guys get it passed at the first time you ran the notebooks. Thanks a lot.

jimxinbo avatar Nov 25 '15 04:11 jimxinbo

Fixed by:

change: for _, label in test_dataiter: label = label.asnumpy() pad = test_dataiter.getpad() real_size = label.shape[0] - pad

to

for _, label, _ in test_dataiter: label = label[0].asnumpy() pad = test_dataiter.getpad() real_size = label.shape[0] - pad

The same strategy applies to simple_bind.ipynb

jimxinbo avatar Nov 25 '15 08:11 jimxinbo