Home > database >  ValueError: Input 0 of layer "sequential" is incompatible with the layer: expected shape=(
ValueError: Input 0 of layer "sequential" is incompatible with the layer: expected shape=(

Time:11-23

https://www.youtube.com/watch?v=z1PGJ9quPV8&t=28s Here is the little project of Cancer dectection, and it has already offer the dataset and colab code, but i got problem when excute

model.fit(x_train, y_train, epochs=1000)

it shows: ValueError: Input 0 of layer "sequential" is incompatible with the layer: expected shape=(None, 455, 30), found shape=(None, 30)

i look at the comments, some people has the same problem

CodePudding user response:

The Tensorflow model expects the first dimension of the input to be the batch size, in the model declaration however they set the input shape to be the same shape as the input. To fix this you can change the input shape of the model to be the number of feature in the dataset.

model.add(tf.keras.layers.Dense(256, input_shape=(x_train.shape[1],), activation='sigmoid'))

The number of rows in the .csv files will be the number of samples in your dataset. Since you're not using batches, the model will evaluate the whole dataset at once every epoch

  • Related