I have reproduced the code and made some adjustments by importing tf_keras
instead of keras, and using tf_keras
consistently throughout the code. This
ensures compatibility with TensorFlow's integrated Keras API.
After making these changes, the code working more efficiently.Please refer
to this gist