The error message you are encountering indicates that there's an issue with eager execution and the use of .numpy() within your TensorFlow model when trying to call model.fit(). The message "numpy() is only available when eager execution is enabled" suggests that, even though eager execution is reported as enabled, some part of your code (likely involving your model or a custom layer) is trying to access tensor values in a non-eager context (which requires eager execution).
You are using tf.compat.v1.enable_eager_execution(), which is related to TensorFlow 1.x compatibility mode, but it could cause confusion when working with TensorFlow 2.x, as eager execution is enabled by default in TensorFlow 2.x (unless you're explicitly disabling it).
Remove the Eager Execution Enablement: tf.compat.v1.enable_eager_execution()
Check Model and Data Types: Ensure that your x_train, y_train, x_test, and y_test are proper numpy arrays or TensorFlow tensors.
Re-save the Model After Loading: After loading the model using tf.keras.models.load_model(f"models/{model_name}.h5"), double-check that the model is compatible for further training.
Use TensorFlow 2.x APIs: If you're using TensorFlow 2.x, avoid using any tf.compat.v1 methods unless absolutely necessary. Stick to the higher-level API provided by TensorFlow 2.x for training, evaluation, and saving models.