Expected shape (None, 8) but got array with shape (8,1)

Eventhough we don't see the full error trace, I think that the model learns and the error comes at the line :

predictions = model.predict(test)

Please confirm this.

The prediction fails because what you should always feed the network with is a numpy array of shape (number_of_samples_to_predict, input_shape). There is always an additionnal dimension at the beginning, this is where you pile up all of the samples that you want to predict. When there is only one sample, you still have to feed a [1, input_shape] array.

To fix this use define your test input like this :

test = np.array([[6,148,72,35,0,33.6,0.627,50]])

now test has shape (1,8) which should run as the model expects (?,8).

Tags:

Python

Keras