Set random seed
print(np.__version__) tf.random.set_seed(42)
Create a model using the Sequential Api
model = tf.keras.Sequential([tf.keras.layers.Dense(1)])
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"]
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) ])