我是Keras的新手,我想創建我的網絡,需要在紙牌遊戲上學習。它需要93個二進制輸入,一個隱藏層有40個神經元和一個輸出神經元,計算得分(從0到25)。Keras輸入形狀錯誤
model = Sequential()
model.add(Dense(input_dim=93, units=40, activation="sigmoid"))
model.add(Dense(units=2, activation="linear"))
sgd = optimizers.SGD(lr=0.01, clipvalue=0.5)
model.compile(loss="mse", optimizer=sgd, learning_rate=0.01)
我想先來計算(做正向傳播)的93個輸入
這是 「s.toInputs()」
[0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 1 1 1 1 0 1 0 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 0 0 1 1 0 1 0 0 0 0 0 0 0 0 0 0 1 0 1 0 0 1 1 0 0 0 0 1 0 1 0 0 0 0 0 1 1 0 0 1 1 0 0 1 0 0 0 0 1 1 0 1]
model.predict(np.array(s.toInputs())
,但我得到錯誤
ValueError: Error when checking : expected dense_1_input to have shape (None, 93) but got array with shape (93, 1)
我該怎麼辦ss正確的參數?
我仍然得到相同的錯誤(我打印數組,它就像你說的),也許我的模型是錯誤的?我的數組只包含網絡的93個輸入,什麼是n_samples和n_attributes? – Ggs
你使用theano還是tensorflow? –
我使用theano – Ggs