Question

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.

No correct solution

Licensed under: CC-BY-SA with attribution
Not affiliated with datascience.stackexchange
scroll top