I have a Keras model and a numpy array that I want to call predict on. Specifically, I have:
a numpy.ndarray called test that looks like this:
array([ 0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 12920, 11891, 4605, 2425, 6780, 5096,
13821, 4405, 10345, 4468, 5910, 11891, 10906, 14994, 12073,
8581, 3544, 13846, 3110, 2425, 3407, 9631, 13846, 4479,
9964, 2556, 4479, 2686, 8895, 10959, 1531, 11891, 1494,
10376, 13846, 12856, 13846, 3110, 2425, 3407, 3267, 181,
4479, 14842, 4639, 7723, 11891, 11449, 2425, 5662, 2282,
5129, 2518, 13846, 4479, 4780, 2598, 4926, 543, 7304,
12020, 8143, 10998, 13846, 12853, 13846, 12856, 11891, 3785,
9131, 7448, 13846, 10376, 13846, 8245, 3788, 12211, 2425,
13614, 10049, 2556, 8245, 1406, 6423, 3110, 2425, 3407,
5726, 2619, 1494, 13694, 7434, 12086, 7304, 3267, 9184])
When I do test.shape, I see:
(180,)
When I do model.predict(test), I get back:
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "...python2.7/site-packages/keras/engine/training.py", line 1152, in predict
x, _, _ = self._standardize_user_data(x)
File "...python2.7/site-packages/keras/engine/training.py", line 754, in _standardize_user_data
exception_prefix='input')
File "...python2.7/site-packages/keras/engine/training_utils.py", line 136, in standardize_input_data
str(data_shape))
ValueError: Error when checking input: expected sequence to have shape (180,) but got array with shape (1,)
Any idea what I'm doing incorrectly?
Thanks!