Your model could not be loaded. Make sure it is a valid h5 file

Hey Chris, thanks for jumping in. I was finally able to install TF2.8.0 which I was not able to do before. It seems that when I completely quit Coursera and reopened the classroom, I got an updated version of the assignment code file. The model is now graded successfully.

1 Like

Great! Glad to hear that!

I used this only but still i am gettign error can u please help me

Hi @OM_TEJASWINI ,

Try with 2.9 Versión, or maybe 2.8:

!pip install tensorflow==2.9.0
!pip install keras==2.9

Hope it helps.

Ok thanks! I tried and it worked

I’ve got a few comments and observations from my experience:

I ran the code in Colab, but the following was missing:
!pip install tensorflow_datasets

We need it in addition to the following:

!pip install tensorflow
!pip install keras

The biggest problem was with contradictory incompatibility of
!pip install protobuf
with respect to packages “tensorflow” and “tensorflow_datasets”. The former requires “protobuf” version <3.20, while the latter requires version >=3.20.

In any case, the following worked for me locally on my laptop with GPU (the grade was 100/100):

tensorflow ‘2.8.3’
keras ‘2.8.0’
tensorflow_datasets ‘4.9.2’
protobuf ‘3.20.3’, which is (a bit) incompatible with tensorflow ‘2.8.3’, but that’s fine: it works

Side observation: I could not upload the model “birds.h5” through Firefox, but it worked through Chrome.

Later I tried the following combination on Colab (it runs fine, but was graded at 0/100 with the grader’s message “Your model could not be loaded. Make sure it is a valid h5 file.”):

!pip install tensorflow==2.12 # 2.12.0
!pip install keras # 2.12.0
!pip install tensorflow_datasets # 4.9.2
!pip install protobuf # 4.23.4, (not 3.19.6, as required by TF 2.8 & 2.9, but 3.19.6 is not supported by TFDS).

Note: TF 2.12 has its own bugs, that’s why I am still on “good old” 2.8.3 (locally on my laptop with both Powershell and Ubuntu), which is more stable.