简体   繁体   中英

ValueError : too many values to unpack

I dont understand the following code. when im executing it is giving the value error too many values to unpack

train_data=[data, Label]
print train_data
for data, Label in train_data:
     print data
     print Label


 output 
 [array([[23., 114., 49., ..., 61., 66., 75.,],
        [134., 345., 123., ..., 252., 249., 255.],
        ....
        [123., 97., 45., ..., 33., 234.,132.],
        [76., 98., 54., ..., 243., 211.,187.]], dtypye=float32), 
        array([0,0,1,0,2,1,1,0,0,2,2,2,0,0,0,0,2,0,0,2,2,2,0,2,2,1,1,0])]

 ValueError Traceback(most recent call last)
      1. print train_data
  --->2. for data,Label in train_data
 ValueError: too many values to unpack

please help me to solve this issue.

Since I don't have your data, I can't try to reproduce your problem. However, I would suggest you try the following.

instead of train_data=[data, Label] use zip(list_a, list_b)

Try this and let me know whether it works

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM