Final_model error

Notice the warning in your first screenshot that explains that Model inputs must come from tf.keras.Input. Something is wrong with the sequencing of the layers in your model. The first (non-input) layer should take the inputs as a parameter and subsequent layers should take some previous layer as a parameter.

Some things to check:

Check that you have uncommented all the lines of final_model, and that the first line of code in that function is still

x = base_model(inputs)

and also that your first line of your base_model implementation passes in inputs as the parameter to its first layer and that it passes the base_model test:


Yes, I uncommented all the lines of final_model

The inputs are predefined,So I just used them to create a first layer in base_model as
x = Dense(128,activation=‘relu’)(inputs)

OK, that part looks fine. You need to keep looking for some way you are not starting your model off with a valid tf.keras.Input.

The next place I can think to look is at the input parameter you pass to the Model in this line:

model = Model(inputs=# YOUR CODE HERE, outputs=# YOUR CODE HERE)

Make sure your input is a keras Input layer

Thank u mam, I got this one but in compiling the model I used this code
< code removed by mentor >

Hi @S.Dheeraj, congratulations on getting final_model() working!

For this next part, first I should mention that it’s against community guidelines to share your code. I’ll remove that from your post, but just so you know for the future. It’s fine to post screenshots of the stack trace like you did.

One comment based on the code you posted - you should not need to add any imports yourself. All necessary imports have already been done for you. You should only being changing code in the places specifically marked with ### YOUR CODE HERE ###

Now on to the debugging:

To debug this part, look at the errors returned by the test code. The first error is the metrics_0_check, so that’s a good place to start. The error message says that wine quality metrics is incorrect and shows you what is expected as well as what result it’s seeing with your code.

So, you need to check your code to see what’s wrong with metrics for wine quality. Please go back and review the instructions right above the code cell and see what it says about setting metrics. I think you might have overlooked this part of the instructions.

Also, as an FYI, if you ever want to look at what the test code is doing, the tests are in the file. You can look at this file by going to the File menu and picking the “Open…” option.

Ok mam,I used loss as binary_crossentropy and metrics as mean_squared_error
even though it showing error.In also the loss used is binary_crossentropy and
metrics as mean_squared_error

OK, I think I see what the issue is now.

Please notice in the instructions where it says, “To set more than one loss, use a dictionary of key-value pairs.”

That means in this part, you should set the loss values for wine_type and for wine_quality:

              loss = {'wine_type' : # YOUR CODE HERE,
                      'wine_quality' : # YOUR CODE HERE

And in this part, you should set the metrics values for wine_type and wine_quality:

              metrics = {'wine_type' : # YOUR CODE HERE,
                         'wine_quality': # YOUR CODE HERE

It is showing list index out of range.

OK, so you’ve passed the metrics tests in test_model_compile() that were failing before and you’re on to a new error.

Take a look at the error message in the stack trace. It shows you the name of the test that’s failing is “wine_quality_loss_check”, so you know something about your wine_quality value is wrong. The “result” value in the error message shows what the test is checking for, and “expected” shows what value the test is expecting to get when it evaluates the expression shown for “result”.

With this in mind, go back and read the instructions about what to set for wine_quality, and look at your code and see what you can figure out about what is wrong in your implementation.

On a more general note:

As the Advanced Techniques specialization progresses, the assignments will leave more and more of the implementation to the student, so if you’re planning to continue with the whole specialization, it’s important that you take time in these early assignments to read the instructions carefully, and make sure you are understanding the concepts well so that you can build a good foundation to help you through the later assignments and get the most out of the courses.

When you do hit problems, fortunately, the test cases in the assignments can be a big help with debugging. Hopefully, the explanation I wrote above will give you some insights on how you can look at these error messages in the future to figure out what’s going on.

Good luck! Write back to say how the debugging went for you on this one.

Yes, I understood how to debug,even though I followed the instructions given still it’s showing the error that’s same error. I used “tf.keras.metrics.RootMeanSquaredError()” for wine_quality metrics and also I tried “mean_squared_error” it’s still showing the same output.
Thank you for giving me suggestion’s for debugging.

You’re welcome, @S.Dheeraj. How did the suggestions work out for you? Were you able to figure out the issue using the error message?

If you are still stuck, please carefully read each word in the name of the test that is failing to make sure which value it is complaining about.

Yes Mam, I understood how to to figure out the issue using the error message but it is showing like this
IndexError: list index out of range
I’m unable to resolve the error because all the remaining testcases had been passed, I tried to make changes in the list but the other testcases is not working.

@S.Dheeraj, that’s the same error you posted a screenshot of, right? That’s the error I’ve been trying to explain how to read. Look at the lines just above the “list index out of range”. Do you see where it says:

"name": "wine_quality_loss_check"

That’s the name I’m saying you should carefully read each word of. It tells you exactly where to look for the problem. The name says “wine_quality” and it says “loss” (not metrics). So, check the value you have for loss for wine_quality.

The value you should set is explained in “result” section of the error and also in the instructions.

Thank you @Wendy for your help