Assignment 3 submission errors

I have converted the h5 file to a JSON file and my submission failed. I think that since the course materials are outdated, the instructions contain old version codes.

I use model.save to save the model
and for convert:

!tensorflowjs_converter --input_format keras \
                       /my_model.h5 \
                       ./

the error I am getting: Can't compile the student's code. Error when checking input: expected dense_input to have 2 dimensions, but got array with shape (None, 150, 150, 3)

Here are the versions:
tenforflowjs: 4.2.0
tensorflow: 2.11.0

What versions do I have to use or is there any other way to generate json files in order to pass the assignment?

Please try the following code:
!tensorflowjs_converter --input_format=keras {saved_model_path} ./

Let me know if you still face the issue.

I am able to get json and the bin file using the code above, but when I upload this to the system, I get the following error:
"Can't compile the student's code. Error when checking input: expected dense_input to have 2 dimensions, but got array with shape (None, 150, 150, 3)"
I have pretty much used many of the versions of TensorFlow and TensorFlowjs. Not sure what causes this error.

Hi @Fatih_KARATAY , some questions to give you a better support:

  • What is the version of TensorFlow that you are using?
  • What is the version of TensorFlow.js that you are using?
  • Have you tried using a compatible version of TensorFlow and TensorFlow.js?
  • Have you tried using the tfjs.converters.save_keras_model function in TensorFlow 2.4 or above to convert the model instead of tensorflowjs_converter?
  • Have you checked the architecture of the model, and the input preprocessing, to ensure they are compatible with the converter?
  • Have you tried modifying the architecture or the input preprocessing of the model to make it compatible with the converter?
    Regards!!
    Juan Solís

I think you meant this post for me. If so, here are some details:

  • the versions that I use are in the main post. I also use the following versions:
    tensorflow-cpu==2.2.0
    tensorflowjs==2.0
    keras==2.2.0
    tensorflow==2.2.0

For convertion:
!tensorflowjs_converter --input_format keras {model_parth} ./ or
!tensorflowjs_converter --input_format=keras {model_path} ./
I am still getting the same error.

I suspect that this is a version issue. Not sure what versions are suitable for this assignment. Wonder if anyone else is having the same issue.

Based on the information you’ve provided, it seems that the versions of TensorFlow and TensorFlow.js that you are using are not compatible with each other. It’s recommended to use TensorFlow 2.2.0 and TensorFlow.js 2.4.0 or later version.

In addition to that, I would suggest you to check if the architecture of the model and the input preprocessing is compatible with the converter, and if not, try modifying the architecture or the input preprocessing of the model to make it compatible with the converter.

You might also want to check if there are any newer versions of the packages you are using to see if that fixes the issue.

Finally, you could try using the tfjs.converters.save_keras_model function in TensorFlow 2.4 or above to convert the model instead of tensorflowjs_converter, it should work better.

Please, tell me if some of this suggestions works for you.

Regards

ok, Here are the versions that I use this time:

tf version: 2.11.0
tfjs version: 4.2.0

Please not that I used many different variations of versions by trial/error and none of them worked for me.

Also, instead of using the converter command, I use tfjs.converters.save_keras_model(model, './')

Still getting the same error:
Can't compile the student's code. Error when checking input: expected dense_1_input to have 2 dimensions, but got array with shape (None, 150, 150, 3)

1 Like

Dear @Fatih_KARATAY ,
Can you please send me your code privately?
Posting code here may violate community guidelines

Dear @Fatih_KARATAY ,
I hope your problem has been solved.

It’s solved. Thank you for the help!

1 Like

Getting “The model in your submission is invalid. Please try again!” while submitting the assignment(C1W3).
I guess the main reason is to incompatibility of dependencies of tensorflow & tfjs, I have tried many versions started from 2.2 to 2.11, but still getting the error.

Please, kindly help me out @Girijesh , Thank you

Dear @Abhijit_Sutar,

Please message me your notebook. I’ll look into it.

@Girijesh may I also send my notebook? I have done 19 different submissions for this coding assignment and failed. I would very much appreciate your help please. thank you

Yes.
Please describe your problem in detail. That would help me.

Dear @Girijesh,
I also encountered the same problem, the code run without any problem and json & bin file already downloaded but still get the following error “The model in your submission is invalid. Please try again!”
I am using tensorflow 2.11.0 and tensorflowjs 4.4.0, can you help me please?

1 Like

hello Girijesh I have send my notebook through PM thank you

1 Like

Thank you very much, I’ll look into it and let you know as soon as I am done.

Hi Girijesh, I finally solved it, thank you so much

Hi Erwin Carlo Gonzales,

Sorry for the late reply, I got sick, that’s why I was not able to work on the notebook.
I just wanted to know if your problem is solved or still exists?

Please let me know.

Hey Girijesh, I have solved it finally. Sorry I was on course 2 and am catching up. You take care and I hope you’re better. Thank you for taking the time to take a look at my notebook

1 Like