Keras unexpected output size

Viewed 64

I'm trying to run predictions on a set of inputs. My model is:

model = keras.Sequential([
    keras.Input(shape=(120, 3)),
    layers.Dense(20, activation='relu'),
    layers.Dense(1, activation='sigmoid'),
])

Summary:

_________________________________________________________________
 Layer (type)                Output Shape              Param #   
=================================================================
 dense (Dense)               (None, 120, 20)           80        
                                                                 
 dense_1 (Dense)             (None, 120, 1)            21        
                                                                 
================================================================

Now, I expect the predict or call on the model with shape (120, 3) to return the a single result. Instead I'm getting:

ValueError: Input 0 of layer "sequential" is incompatible with the layer: expected shape=(None, 120, 3), found shape=(120, 3)

or if I try to get the right shape using np.array([original_input]), so it's (1, 120, 3), I get a result with 120 values instead.

What am I missing - how do I get a single result in this situation? (or even better - how do I pass a number of (120, 3) elements?)

0 Answers
Related