0
$\begingroup$

I've this item:
['6', '1', '6', '843537', '3', '0', '5', '1006709', '3', '1', '4']
with shape: (11,)
but when go to predict with:

print(np.array(data).shape)
data = np.expand_dims(data, axis=0)
print('Predict: ' + model.predict(sc.transform(data)))

i get this error:

ValueError: Input 0 of layer "sequential_2" is incompatible with the layer: expected shape=(None, 1, 11), found shape=(None, 11)

how can I do the fix?

$\endgroup$

1 Answer 1

0
$\begingroup$

You simply need to add another dimension to your data, you can either use numpy.expand_dims again or use numpy indexing to add the two extra dimensions at once:

data = np.expand_dims(np.expand_dims(data, axis=0), axis=0)
# or
data = data[None, None, :]

print(data.shape)
# (1, 1, 11)
$\endgroup$
1
  • $\begingroup$ it say: Cast string to float is not supported $\endgroup$
    – Mariano
    May 6, 2022 at 13:37

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.