Week 4 assignment average SSI of 0.87 max

Hello there,

I’m reaching to you for some help on the assignment lab.
I can’t reach the .95 grading threshold on the saliency map model even after matching with the ungraded lab, tweaking the model parameters, adding a last maxpooling layer as I saw in one of the Topics here, not shuffling, paying attention to the loss function choice

(I think I maybe need to choose a different one that I won’t quote here but when I try it with the non sparse version of it I get an error that I can’t find how to solve :
ValueError: Shapes (None, 1) and (None, 2) are incompatible)

But maybe this is not on the loss function.

I also tried with the loss adapted to binary situations but ended with this error :
ValueError: logits and labels must have the same shape, received ((None, 2) vs (None, 1)).

The labels are one hot encoded as asked.
The absolute value of the gradients is done.
In the GradientTape, the loss is the ‘non sparse’ version.

I’m on it for 4 hours now and it seems to be a minor error so that is driving me crazy. Thanks for your consideration have a great day!

1 Like

Pay special attention to the do_salience function, especially this line

Define the expected output array by one-hot encoding the label

The length of the array is equal to the number of classes

I think its a critical point here!

In the GradientTape, the loss is the ‘non sparse’ version. - This is right, but its different at model.compile.

Try and if still cannot get through, you can send me your notebook as a private message I will have a look at it later on.

Hello Benjamin

Can you share screenshot of error you are getting you mentioned above.


im getting (None, 1) and (None, 2) are incompatible also - i could really use a hint

i got it to run stand by on results


Kindly share the screenshot of the error you got, for better help.


Please do not share your code on the forum.

did not mean to do that - im not getting an error code - im just under the .95 by a margin now i got it to run - i thought it might be the expected output or the loss function im using sparse categotrical when i attempt to change it at the compile stage i get an error

this error image??

some of the text got cut off Sorry Deepti- im not encountering an error im just a little perplexed by what im seeing as opaque criteria and maybe redundant instructions im not sure what my exact constraints are im currently tweaking momentum

am i supposed to calculate ssim


You mentioned getting value error incompatible??

If the issue not getting the desirable accuracy, then look into your model again, value error incompatible shows you to look if you have recalled correctly your input shape as per the assignment’s instructions.

If unable to find solution, kindly send your notebook via DM. Click on my name and then message.


Hello Paul,

Issues with your notebook assignment.

  1. You didn’t define label but define only image in def augment image grader cell. after resizing the image, define label with tensor one_hot code.

  2. While defining model, you do not require to import files again in the cell separately
    from tensorflow.keras.models import Sequential
    from tensorflow.keras.layers import Conv2D, MaxPooling2D, GlobalAveragePooling2D, Dense, Dropout
    from tensorflow.keras.optimizers import RMSprop

  3. Incorrect activation for the last dense layer, it is not a binary classification but probably for each of the 2 classes(categories), so which activation would you use for multi class category??

  4. The below code needs correction, make sure you used correct image shape while one_hot encoding.
    Define the expected output array by one-hot encoding the label

  5. Although they have mentioned it has optional step, but they want you to write the code for the below statement which you have left blank
    Optional: superimpose the saliency map with the original image, then display it

  6. the most important issue with your notebook, in your configuration model training, you have applied two optimisers also you have used model load weight. You only need to compile model according to the instructions mentioned above the grader cell which clearly states you to use RMSprop optimizer with a learning rate of 0.001, even loss you have used two types, kindly use only categorical_crossentropy. I am sharing a screenshot of your incorrect model compile

overall, I also got a doubt if you have edited something outside of ##START AND END CODE HERE##, so I sincerely suggest you to do these correction with a fresh copy of your assignment for better comparison, learning and successful submission of your assignment.

Kindly let me know once your issue is resolved.


{moderator edit: code upload removed}

Please do not post your notebook on public post. I already have replied to the notebook you sent me through DM.

i found a couple of things more challenging about this week- it is the course finale- so I’m not shocked that the code cells were almost blank for this assignment -plus typically there is an exhaustive Colab with Laurence doing a walk through and that did not happen -we got a much more abbreviated variety of that - and the final assignment seems to also focus on a small percentage of the ideas that were embraced - one dimension of the week is almost an afterthought unless we are to employ gradcam for instance in this scenario - it is possible to elicit salience mapping on 18 epochs without doing a model.fit - since we have the weights/// i was wondering (as its not entirely spelled out or i missed it somehow) -but am i supposed to just get the 2nd salience mapping without running the longer epochs ? i hope this isn’t too much of a bother and if i figure this out I’ll update to let u know so as not to trouble you-further - thanks again I just went through your instructions again

How can you do salience mapping without training your correct model (which you need to correct)

Kindly read the comments point by point, so you don’t get such doubts. Debugging is not corrected codes but correction, re execution, re training for better outcome of successful submission.


i thought it was like a thread i have to step up my game i did not

its clear to me the three epochs have to be trained - i’m still unsure about the 18 i was
with the provided weights if it was necessary to train the latter - ill keep at it -

Kindly be brief and point in the right direction of your doubt.

If you are stating about the optional step then you could try once without that step and download your model for submission. If you didn’t clear, then try the optional step as the next step mention you to do so