from tensorflow.keras.optimizers import Adam from tensorflow.keras.optimizers import Adam # - Works from tensorflow.keras.optimizers import adam # - Does not work from keras.optimizers import Adam # - Does not work from keras.optimizers import adam # - Does not work
Here is what the above code is Doing:
1. Importing the Adam optimizer from the tf.keras.optimizers module.
2. Importing the Adam optimizer from the tf.keras.optimizers module.
3. Importing the Adam optimizer from the keras.optimizers module.
4. Importing the Adam optimizer from the keras.optimizers module.
The first two lines of code are equivalent. The third and fourth lines of code are not.
The reason the third and fourth lines of code are not equivalent is because the keras.optimizers module is not part of TensorFlow. Keras is a separate library that is not part of TensorFlow.
The reason the third and fourth lines of code are not equivalent is because the keras.optimizers module is not part of TensorFlow. Keras is a separate library that is not part of TensorFlow.
If you want to use the Adam optimizer with TensorFlow, you must use the tf.keras.optimizers module.