C3W1 Bird Box - 'batch_shape' unrecognized value in final save

I am having an issue with the final step of the birdbox assignment. My model runs, I am able to classify and localize birds in each image, and I get IOUs and am able to save it to temp_model.h5. However, the final step, when I try to save it as ‘birds.h5’, I receive the following error. Any thoughts?

---------------------------------------------------------------------------
ValueError                                Traceback (most recent call last)
<ipython-input-2-21180693577e> in <cell line: 2>()
      1 # Load the model you saved earlier
----> 2 model = tf.keras.models.load_model("temp_model.h5", compile=False)
      3 
      4 # Re-save the model with the compatible TF version
      5 model.save("birds.h5")

1 frames
/usr/local/lib/python3.10/dist-packages/keras/engine/input_layer.py in __init__(self, input_shape, batch_size, dtype, input_tensor, sparse, name, ragged, type_spec, **kwargs)
    134         input_shape = batch_input_shape[1:]
    135     if kwargs:
--> 136       raise ValueError(f'Unrecognized keyword arguments: {list(kwargs.keys())}')
    137 
    138     if sparse and ragged:

ValueError: Unrecognized keyword arguments: ['batch_shape']

Hi @anakha272

Check a similar thread but not related to your assignment. this could be issue with tf.version, so follow the step mentioned

let me know if it works!

@chris.favila another assignment of the same course with the same issue, so tagging you for your notification.

Regards
DP

2 Likes

So, should those two lines be run before everything else? Or to replace the following lines:

!pip install tensorflow==2.8.0 --quiet
!pip install keras==2.8.0 --quiet

first check which version of the tf is your notebook using, then in the same assignment as per instructed in the post, you need to use the tf version which is compatible to run the codes.

If you are using an updated assignment chances are the code cell might be already added.

1 Like

Hi Deepti and Rahul! Thank you for reporting! The notebook is now patched in the public repo. Learners can reload the Colab from the classroom to see the changes. Another way is to add these two lines at the top of the existing notebook, then run all the cells again until you generate a new model file:

!pip install tensorflow==2.15.0 --quiet
!pip install keras==2.15.0 --quiet

Hope this helps!

2 Likes

Thank you both! It works now!

1 Like