C3 W3 Question duplicates: Issues in Questions 4, 5 - Classify, Predict

Hello,

While submitting the code for Question 4 (Classify), I get the following error:
InvalidArgumentError: {{function_node _wrapped__Pack_N_2_device/job:localhost/replica:0/task:0/device:GPU:0}} Shapes of all inputs must match: values[0].shape = [10240] != values[1].shape = [10240,10240] [Op:Pack] name: stack

My submitted codes for the first three questions are correct, and I submitted them to the grader as well, to cross-check. I have gone through the common problems in Question 4 including incorrect dtype for input_1 and input_2 in Question 1, or on slicing of data for recovering v1 and v2 (hints after the Triplet Loss Function). Somehow, I am unable to troubleshoot the issue, and have also read the instructions carefully. I would be really grateful for any tips on how to resolve the issue, as it is affecting both Questions 4 and 5. On submitting, I did get partial credit for Question 5, though I couldn’t identify the exact issue.

My lab ID is ugtstetsekth

I would be really grateful for any help. Thank you!

I’m not familiar with the details of this assignment, but anytime you get a shape mismatch, it should be clear where you need to start your analysis, right? So what are the two objects in question and what role do they play in the computations? Why are they not the same shape? What shape should they be? Print the shapes of all the input objects and intermediate objects being created in your code. Where do things go off the rails?

Debugging is a key part of the job, not just some annoying afterthought. You start with the error message. What does it mean? That’s pretty clear in this case, right? So then you need to work backwards one step at a time to figure out where the problem is using the kind of thought process I described above.

1 Like

Thank you for the advice! There was a problem in my code for the cosine similarity matrix, which I have corrected now and completed both the problems successfully.

1 Like

It’s great to hear you were able to solve the problem under your own power. Onward! :nerd_face: