Error when checking target: expected dense_3 to have shape (3,) but got array with shape (1,)

后端 未结 9 1778
不思量自难忘°
不思量自难忘° 2020-12-04 17:26

I am working on training a VGG16-like model in Keras, on a 3 classes subset from Places205, and encountered the following error:

ValueError: Error when chec         


        
9条回答
  •  遥遥无期
    2020-12-04 18:19

    For me, this worked.

    from keras.utils import to_categorical
    
    num_labels=10 #for my case
    
    train_labels=to_categorical(train_labels,10)
    test_labels=to_categorical(test_labels,10)
    

    Specifying the number of labels as an argument while categorically encoding my labels helped train effectively on my training set.

提交回复
热议问题