'TypeError: 'numpy.int64' object is not iterable for the oxflower17 dataset
I am getting an TypeError while running the below sample code.
dic = {0: 'Daffodil', 1: 'Snowdrop', 2: 'Daisy', 3: 'ColtsFoot', 4: 'Dandelion', 5: 'Cowslip', 6: 'Buttercup', 7: 'Windflower', 8: 'Pansy', 9:'LilyValley', 10: 'Bluebell', 11: 'Crocus', 12: Iris', 13: 'Tigerlily', 14:'Tulip', 15: 'Fritillary', 16: 'Sunflower'}
Plotting the content of a sample
sample = 72
plt.imshow(X[sample]);
print('y =', np.squeeze(y[sample]))
for i in [i for i,x in enumerate(y[sample]) if x == 1]:
print('')
print('y =', i, ';', 'the sample', sample, 'corresponds to a(an)', dic[i])
Getting an error : y = 13
TypeError Traceback (most recent call last) in () 6 print('y =', np.squeeze(y[sample])) 7 ----> 8 for i in [i for i,x in enumerate(y[sample]) if x == 1]: 9 print('') 10
TypeError: 'numpy.int64' object is not iterable print('y =', i, ';', 'the sample', sample, 'corresponds to a(an)', dic[i])
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
