np_utils.to_categorical Метод Keras выдает ошибку, когда я даю ему вектор элемента [962], который содержит 3 класса [1,1,1, ..., 2,2,2, ... 3,3 , 3].
Используемый код:
from keras.utils import np_utils
Y_train = np_utils.to_categorical(testY, 3)
и я получаю эту ошибку:
---------------------------------------------------------------------------
IndexError Traceback (most recent call last)
<ipython-input-24-9b7d3117ff6a> in <module>()
1 print(trainY[720])
----> 2 Y_train = np_utils.to_categorical(testY, 3)
3 print(Y_train[100])
/usr/local/lib/python3.6/dist-packages/keras/utils/np_utils.py in to_categorical(y, num_classes, dtype)
32 n = y.shape[0]
33 categorical = np.zeros((n, num_classes), dtype=dtype)
---> 34 categorical[np.arange(n), y] = 1
35 output_shape = input_shape + (num_classes,)
36 categorical = np.reshape(categorical, output_shape)
IndexError: index 3 is out of bounds for axis 1 with size 3