IndexError: index 119 is out of bounds for axis 1 with size 119

976 views
Skip to first unread message

harsh sharma

unread,
Aug 22, 2018, 7:14:53 AM8/22/18
to Keras-users
i am a beginner and try to understand convolution neural networks

my code giving me this error :
Traceback (most recent call last):
<module>
    label = keras.utils.to_categorical(label,119)
  File "/home/cerebroz/.local/lib/python3.5/site-packages/keras/utils/np_utils.py", line 32, in to_categorical
    categorical[np.arange(n), y] = 1
IndexError: index 119 is out of bounds for axis 1 with size 119


here is my code:-

label = np.array(label)
print(label.shape)
(10222,)
data = np.array(data)
end = LabelEncoder()
label = end.fit_transform(label)
print(label.shape)
(10222,)
cla = max(label)
#print()
label = keras.utils.to_categorical(label,119)
'''

Matias Valdenegro

unread,
Aug 22, 2018, 7:25:57 AM8/22/18
to keras...@googlegroups.com

If your class indices go from 0 to 119, then you have 120 classes, not 119.

Reply all
Reply to author
Forward
0 new messages