I trained a model in Keras with input dimension 15 and output dimension 1. Then I tried to predict the output for a single input np.array, which I chose to be a toy example np.arange(15). However, the input is not accepted. Can someone tell me where the problem is? Here is the code for a simplified problem:
import numpy as np from keras.models import Sequential from keras.layers import Dense X = np.arange(15) Y = 0 model = Sequential() model.add(Dense(32, input_dim=15, activation='relu')) model.add(Dense(32, activation='relu')) model.add(Dense(1)) model.compile(loss='mean_squared_error', optimizer='adam') model.fit(X, Y, epochs=10, verbose=1, batch_size=batch_size) model.predict(X)
The following error occurs: ValueError: Error when checking input: expected dense_4_input to have shape (15,) but got array with shape (1,). But then again, the input clearly has the correct shape. What is going on here? Thanks for your help!