The issue is that the shapes of the inputs to the model do not match the expected shapes defined in the model. You need to ensure that the shapes of the input variables (train_X and train_y) match the expected input shapes defined in the model. You can check the shapes of the input variables using the shape attribute, and you can also check the shapes of the input placeholders in the model definition to ensure they match.
Here's an example of how to modify the code to fix the issue:
# Check the shapes of the input variables
print(train_X.shape)
print(train_y.shape)
# Ensure the shapes of the input variables match the expected input shapes defined in the model
# If the shapes do not match, you may need to reshape or pad the inputs to match the expected shapes
# For example, if the shape of train_X is (None, 1645), you can reshape it to (None, 4958) using the following code:
train_X = train_X.reshape((-1, 4958))
# Add the callback function to log the loss and accuracy during training
callback_list = [tf.keras.callbacks.EarlyStopping(monitor='val_loss', mode='min', restore_best_weights=True),
tf.keras.callbacks.ReduceLROnPlateau(monitor='val_loss', mode='min', factor=0.1, patience=3, verbose=1, min_lr=0.0001)]
# Add the validation data
model.compile(optimizer='adam', loss='binary_crossentropy', metrics=['accuracy'])
model.fit(train_X, train_y, epochs=3, validation_data = (test_X,test_y), callbacks=callback_list, batch_size=16)
This code prints the shapes of the input variables and reshapes the train_X input to match the expected shape defined in the model. It also adds the callback function to log the loss and accuracy during training.