Keras input shape error

Viewed 4984

I'm new to Keras and I am trying to create my network which needs to learn on a card game. It takes 93 binary inputs with a hidden layer with 40 neurons and a single output neuron which computes a score (from 0 to 25).

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)

I'm trying first to compute (do a forward propagation) of the 93 inputs

this is "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())

but i get the error

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

How do I pass the correct parameters?

3 Answers

The reshaping thing works well. Reshape the array to (batch_size, your_input_dimensions)

np.reshape(batch_size, input_dimesions)

Related