2021年4月3日星期六

What is the issue with my last dense keras layer?

I am working on a small NN in keras for multi-class classification problem. I have 9 different labels and my features are also 9.

My train/test shapes are the following:

Sets shape:  x_train shape: (7079, 9)  y_train shape: (7079,)  x_test shape: (7079, 9)  y_test shape: (7079,)  

But when I try to make them categorical:

y_train = tf.keras.utils.to_categorical(y_train, num_classes=9)  y_test = tf.keras.utils.to_categorical(y_test, num_classes=9)  

I get the following error:

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

Here is more info about the y_train

print(np.unique(y_train)) # [1. 2. 3. 4. 5. 6. 7. 8. 9.]  print(len(np.unique(y_train))) # 9  

Anyone would know what the problem is?

https://stackoverflow.com/questions/66937155/what-is-the-issue-with-my-last-dense-keras-layer April 04, 2021 at 08:57AM

没有评论:

发表评论