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

前端 未结 1 682
青春惊慌失措
青春惊慌失措 2020-12-21 18:10

I am trying to predict using the learned .h5 file. The learning model is as follows.

model =Sequential()
model.add(Dense(12, input_dim=3, activation=\'relu\'         


        
相关标签:
1条回答
  • 2020-12-21 18:57

    The shape of x is obviously (3,1), but the above error continues.

    You are right, but that's not what keras expects. It expects (1, 3) shape: by convention, axis 0 denotes the batch size and axis 1 denotes the features. The first Dense layer accepts 3 features, that's why it complains when it sees just one.

    The solution is simply to transpose x.

    0 讨论(0)
提交回复
热议问题