0

I have trained this model:

from keras.layers import concatenate
from keras.layers import Input, Dense, Masking
from keras.models import Model

x_in = Input(shape=(5,), name='x_in')

s_in = Input(shape=(18,), name='s_in')

s_masked = Masking(0.0)(s_in)

z = concatenate([x_in,s_masked])

dense_1 = Dense(40, kernel_initializer='normal', activation='relu', name='dense_1')(z)
dense_2 = Dense(40, kernel_initializer='normal', activation='relu', name='dense_2')(dense_1)

output = Dense(1, kernel_initializer='normal', name = 'output')(dense_2)

model = Model(inputs=[x_in,s_in], outputs=output)

model.compile(optimizer='adam', loss={'output':'mean_squared_error'})
model.fit({'x_in': x_training,'s_in':s_training},{'output':y_training},batch_size=30, epochs=10, validation_split=0.3, shuffle=True, callbacks=[plot_losses])

I want now to predict now. But due to the fact that I have multiple inputs, I didnt know how to use model.predict().

When I try:

predictions = model.predict(x_testing, s_testing)
print predictions

I get this error:

The model expects 2 input arrays, but only received one array. Found: array with shape (1710, 5)

I don't understand it because I gave two arrays x_testing and s_testing

1 Answer 1

1

You should feed your inputs as a concatenated array, as you have done when building your model (inputs=[x_in,s_in]):

predictions = model.predict([x_testing, s_testing])
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.