Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Regarding Some Potential Issues, Warnings and Changes in Code due to Tensorflow and Keras Version Change #648

Open
Shailya-Ds-Or opened this issue May 9, 2024 · 0 comments

Comments

@Shailya-Ds-Or
Copy link

Current Tensorflow Version: 2.16.1
Current Keras Version: 3.3.2

  1. Providing input shape in first layer of the model, be it any type of layer (Dense / Conv2D) throws a warning telling to add InputLayer separately to mention input shape. Use InputLayer as the first Layer.
1
  1. Explicitly convert steps_per_epoch int (Using int()) to avoid "Ran out of Training" Error in case value provided in parameter isn,t integer.

  2. !wget doesn't work in Jupyter Notebook. Use "import wget" works.

2
  1. Using tensorflow_hub.KerasLayer to get pretrained model from Tensorflow Hub and using it as a Layer in Sequential Model gives an error "ValueError: Only instances of keras.Layer can be added to a Sequential model. Received: <tensorflow_hub.keras_layer.KerasLayer object at 0x7a4ac7e30f40> (of type <class 'tensorflow_hub.keras_layer.KerasLayer'>)".
3

I didn't find any specific reason for this but general understanding i got from searching is this issue developed after keras got updated to Version 3 and the issue is not yet resolved.

One simple solution that worked for me is setting environment variable "TF_USE_LEGACY_KERAS = 1" at top of the notebook works. ( Tells tensorflow to use older keras version in the notebook where the environment variable is set).
4

  1. Using Pre-Trained Models from "tf.keras.applications" results in some pretty horrible accuracy when used with own data (same code provides great accuracy when used in colab, which uses tensorflow version 2.15 currently and hence older keras version).
    I didn't find any specific reason for this too, but setting environment variable "TF_USE_LEGACY_KERAS = 1" works at top of the notebook works.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant