A.omrani
A.omrani

Reputation: 43

Error when checking input: expected dense_input to have 3 dimensions

I have a data and I'm trying to fit it with Keras model and my train_data shape (161,25)

model=keras.Sequential([
keras.layers.Dense(64,activation=tf.nn.relu,input_shape=(train_data.shape)),
keras.layers.Dense(64,activation=tf.nn.relu),
keras.layers.Dense(1)])

now when I want to fit train_data as follows

model.fit(train_data,train_labels,epochs=500,validation_split=0.02,verbose=0)

it says that

Error when checking input: expected dense_input to have 3 dimensions, but got array with shape (161, 25)

any suggestion?

Upvotes: 0

Views: 1536

Answers (1)

A.omrani
A.omrani

Reputation: 43

I found my problem and I answer it here in case if anybody else have this problem too: so my input shape was (161,25) it means that we have 161 data that each one have 25 features and we want to give each 25 features of each data to the network so we change the first layer from:

keras.layers.Dense(64,activation=tf.nn.relu,input_shape=(train_data.shape)),

to:

keras.layers.Dense(64,activation=tf.nn.relu,input_shape=(train_data.shape[1],)),

Upvotes: 1

Related Questions