Keras has a problem with the input dimension. My first layer looks like this:
model.add(Dense(128, batch_size=1, input_shape=(150,), kernel_initializer="he_uniform", kernel_regularizer=regularizers.l2(0.01), activation="elu"))
As you can see the input dimension should be (150,) and with the fixed batch_size it is (1, 150)
My data has dimension (150,) and could be for example a numpy array with 150 zeros.
old_qval = model.predict(old_state_m)
Here I call the model to make a prediction. Normally Keras should automatically add the batch size as an extra dimension so I should end up with (1, 150) which would work. But Keras adds the dimension for the batch size at the wrong place and I end up with (150, 1). I tried tensorflow and theano backend.
Do I have a bug in my code or is it a problem with Keras?
How can I fix the problem? I could reshape my input data but it already has the needed shape of (150,) and should be fine. What else could I do?
If I should provide more data or code feel free to ask.
model.predict(X)
the first axis inX
is always an index in a batch. So if you want to predict on one sample, do something likeX = np.expand_dims(X, axis=0)
$\endgroup$