-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
Comments
Hi, Shailya. Are you able to fit the model after explicitly being able to convert steps_per_epoch to int to avoid running out of data? The value provided to the eteps_per_epoch is already an integer in my case. This doesn't work in the Tf 2.17.0 version. So, I had to create another env for tf 2.15.0 that works like the videos without converting to int. |
Maybe you need to use len(training data) / batch size if you have used batching while preparing training data. |
Hi Shailya, Thank you SO much for solving a glitch in my notebook. I imported "os" at the beginning of my notebook and set "os.environ["TF_USE_LEGACY_KERAS"] = "1" like you suggested and it worked!! : ) |
You can also wrap the hub layer in the IMAGE_SHAPE = (224, 224)
# Download the pretrained model and save it as a Keras layer
resnet_url = "https://tfhub.dev/google/imagenet/resnet_v2_50/feature_vector/4"
feature_extractor_layer = hub.KerasLayer(resnet_url,
trainable=False, # freeze the already learned patterns
name="feaure_extraction_layer",
input_shape=IMAGE_SHAPE+(3,))
# Create our own model
resnet_model = tf.keras.Sequential([
tf.keras.layers.Lambda(lambda x: feature_extractor_layer(x)),
layers.Dense(10, activation="softmax", name="output_layer")
]) |
Current Tensorflow Version: 2.16.1
Current Keras Version: 3.3.2
Explicitly convert steps_per_epoch int (Using int()) to avoid "Ran out of Training" Error in case value provided in parameter isn,t integer.
!wget doesn't work in Jupyter Notebook. Use "import wget" works.
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'>)".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).

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.
The text was updated successfully, but these errors were encountered: