Hi
I got the following error “Your model could not be loaded. Make sure it is a valid h5 file.”
when I try to load the h5 file.
I saw that other people got the same error in the past, but I did not found the solution for this.
Thanks, Eyal
Hi
I got the following error “Your model could not be loaded. Make sure it is a valid h5 file.”
when I try to load the h5 file.
I saw that other people got the same error in the past, but I did not found the solution for this.
Thanks, Eyal
@Eyal_Tuzon,
How large is your birds.h5 file?
I just tried creating a new birds.h5 and submitting it and it worked fine for me. My file is ~33.3MB. Is yours a similar size?
Also, notice the comment for Exercise 5 to avoid using experimental.SGD for now.
See this post for more info: Problem with submitting assignment 1 - #7 by chris.favila
Hi Wendy
My file is 16MB.
Thanks, Eyal
Hi Wendy
My issue was that I used tf.keras.optimizers.experimental.SGD
instead of tf.keras.optimizers.SGD
Thank you very much for your help
my h5 file is 16 mb & i used tf.keras.optimizers.SGD, but i got the same error.
@AMIT_KUMAR_SANGER, the only things I can think of are:
Is there any possibility that the h5 file you’re looking at was created with the experimental.SGD? FWIW, if I use experimental, my h5 is ~16 mb, but if use the regular SGD, it’s ~33 mb.
Are you running in your own environment? If so, there may be some version-related issue that we haven’t discovered yet. Can running from Google Drive to see if it’s any different?
If neither of these is the issue, can you DM me a copy of your ipynb and I can take a look to see if I notice anything suspicious.
Hi @Wendy
My h5 file is 31.5 mb, and I used the regular SGD.
I also have this problem.
Do you happen to know anything about the possible reasons?
Same here, my h5 file is 33.1 mb, and I used tf.keras.optimizers.SGD. The h5 file cannot be loaded - “Your model could not be loaded. Make sure it is a valid h5 file.”
I got the same problem. Used tf.keras.optimizers.SGD as required. The model file is 32.35 mb.
I have the same problem, with a file size of 32.5MB
Same problem here! My file is ~33.1 Mb, I use tf.keras.optimizers.SGD
as required and my model summary looks the same as in expected output. Still I am getting “Your model could not be loaded. Make sure it is a valid h5 file.” I was also able to run tf.keras.models.load_model("birds.h5")
in colab and redo the evaluation step without issues.
@DKh, @Ahmed_Yassin, @Yiqiang_Song, @Peng_Chen1, @Ashkan_Moradi: With so many people seeing the same problem all of a sudden, it sounds like a problem with the platform. I just tried with my old birds.h5 file (~33 Mb) and it is working for me now.
Please try again to see if it is fixed for you, too.
@Wendy, I tried again, and still got the same error.
@Wendy It didn’t work for me either. I took a stab at it, and I have a hypothesis that the issue may be due to TF versions mismatch. So by default Colab currently uses TF 2.11. When I tried to read the birds.h5
file locally with TF 2.9 (Apple silicon fwiw) I got an error too
M = tf.keras.models.load_model("/Users/.../Downloads/birds.h5")
Traceback (most recent call last):
....
TypeError: weight_decay is not a valid argument, kwargs should be empty for `optimizer_experimental.Optimizer`.
Note, that I am able to load the very same file in Colab. It was reported that the issue might be due to TF version 2.11 (hence quite recent). @Wendy may I ask you, how old is your old birds.h5 file?
@DKh, your theory is a good one! Thanks for running this down! The old birds.h5 I tried wasn’t as old as I thought - only from Jan. 2023. I tried another one I made on Feb 7th, 2023 and that also worked fine. But it’s possible the switch to v2.11 was after that. People seemed to start having troubles starting Feb. 11th.
I re-ran myself to create a new birds.h5 and get the same error you’re seeing when I submit this new file, even though it loads just fine in Colab. I think you’ve nailed the issue. I’ve submitted an error so the staff can take a look tomorrow. Thanks for your debugging!
Hi everyone! Thank you for reporting this! There is indeed a compatibility issue between the grader and the default TF version in Colab. We’ve marked the grader for an update but for now, it will be quicker to downgrade some of the packages to avoid the errors mentioned. If you open the notebook again from the classroom, you will see this code before the imports:
!pip install tensorflow==2.6.0
!pip install keras==2.6
You can also add it in your existing solution notebook before running the cells again to generate a new h5 file. The output should now be loaded successfully by the autograder. Hope it also works on your end!
Thanks Wendy and Chris! Downgrading tensorflow works for me.
Hello, I can no way install TF 2.6.0. The earliest is now available from 2.8.0. I have tried it with TF2.9, Keras 2.9 as well as TF 2.12. Nothing worked. Now, I am trying to install TF 2.6, it won’t install. I am struggling to submit my assignment for grading from last night and still with no luck. This assignment is so poorly designed and maintained and the grader is not anything different. This is frustrating.
So, TF 2.6.0 certainly does not work. Even if you try with TF 2.8, you face many problems as well. Could you please tell me how can I build my model and how should I submit it for successful grading/
Hi! Welcome to the community, and thank you for reporting this! We are now looking into this particular assignment. Can you tell us what issues you are facing with TF2.8? Thank you!