1

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

1 Answer 1

2

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,:])
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.