Home > Mobile >  why I'm getting this error "Input 0 of layer "dense_30" is incompatible with the
why I'm getting this error "Input 0 of layer "dense_30" is incompatible with the

Time:03-31

Set random seed

print(np.__version__) tf.random.set_seed(42)
  1. Create a model using the Sequential Api

     model = tf.keras.Sequential([tf.keras.layers.Dense(1)])
    
  2. Compile the model

     model.compile(loss=tf.keras.losses.mae,# mae is short for mean absolute error
     optimizer = tf.keras.optimizers.SGD(), # sgd is short for stochastic gradient descent             
     metrics=["mae"] 
    
  3. Fit the model

     model.fit(X, y, epochs=5) // here the error
    

CodePudding user response:

You need to add an input layer, ex:

model = tf.keras.Sequential([  tf.keras.layers.InputLayer(input_shape=(1,)),  tf.keras.layers.Dense(1) ])
  • Related