model = models.Sequential()
model.add(layers.Dense(10, input_dim=x_train.shape[1], activation='relu'))
model.add(layers.Dense(1, activation='sigmoid'))
Runtime warning:
/home/khteh/.local/lib/python3.12/site-packages/keras/src/layers/core/dense.py:87: UserWarning: Do not pass an `input_shape`/`input_dim` argument to a layer. When using Sequential models, prefer using an `Input(shape)` object as the first layer in the model instead.
Hi @khteh, thanks for posting this issue. When trying to build a Sequential model pass an Input object to your model, to define the input shape. This will resolve the warning.
model = models.Sequential()
model.add(layers.Input(shape=(x_train.shape[1],))) # Specify the input shape
model.add(layers.Dense(10, activation='relu'))
model.add(layers.Dense(1, activation='sigmoid'))
You can read more about specifying input shapes in sequential models here.