Reputation: 503
Im trying to predict a manually encoded data with my keras model but it doesnt work:
print(np.array([5.1, 3.5, 1.4]).shape)
prediction = model.predict(np.array([5.1, 3.5, 1.4]))
Gives me:
(3,)
ValueError: Error when checking input: expected dense_13_input to have shape (3,) but got array with shape (1,)
How can I solve this? Thanks
Upvotes: 1
Views: 171
Reputation: 22021
you have to add the batch dimension (n_batch, feat_dim) ==> (1,3)
inp = Input((3))
x = Dense(10)(inp)
model = Model(inp, x)
X = np.array([5.1, 3.5, 1.4])
model.predict(X[None,:])
Upvotes: 2