C1_W3_Assignment # UNQ_C1: error - wrong shape wrong output

Hello,

I am getting the error:

(Solution code removed, as sharing it publicly is against the honour code of this community)

Thanks for any help/ideas!

Hi @edgarbc,

Can you share your lab ID with me ? In the assignment, when you click the top right “Help” button, a panel will open and your lab ID will be shown at the bottom.
I shall take a look.

When you reply back, kindly tag me in the post so that I’m notified.

Thanks,
Mubsi

Hi @Mubsi ,

My lab ID is aqvowduz

Thanks for looking into this!

Best,
Edgar

Hi @edgarbc,

In your Ex 1, when calculating the categorical values of y you were hardcoding the value of number of classes. As a rule, remember, unless specifically asked to do so, never use hardcoded or global values in the graded functions.

You can take a look at your Ex 1 for more information, it runs successfully now.

Best,
Mubsi

Oh I see. Thanks for your help @Mubsi !

1 Like

Hello @Mubsi,

I am also stuck with my UNQ_C1 def_get_sub_volume exercise - even after reading the forum and discourse posts - and was hoping you could help me as well.

The test cell is showing me:
[…]
Error: Wrong shape. for variable 1.
Error: Wrong output. for variable in position 1.
[…]
1 Tests passed
2 Tests failed

I presume the error is somewhere in the one-hot encoding but I can’t figure it out.

My labID is : dqfvmaab

Thanks for your help! It’s much appreciated :slight_smile:

Christian

I think I could resolve the issue.

I hadn’t specified the num_classes parameter when applying the keras.utils.to_categorical method to y in order to one-hot-encode the label array y.

After defining the num_classes parameter by setting it equal to the num_classes variable that is input to the def_get_sub_volume, the test cell showed the expected output without any error messages.

Hope this helps someone.

1 Like

Hi @cagschwarz,

Glad you could resolve it on your own.

Cheers,
Mubsi

Hi @Mubsi ,
Lab ID gzghtoqn
I am stuck with errors for quite a while now. My course deadline is tonight so any help is appreciated.
Error: Wrong output. for variable in position 0.
Error: Wrong output. for variable in position 1.

The surprising bit is that the next section displays the expected MRI image accurately. So, I’m not sure what I’m missing.

Thank you!

Hi @Amrita,

My apologise for getting back to you this late.

I was looking at your assignment, and I’m happy to see that you passed all of the tests.

Let me know if there’s anything else I could help you with.

Happy learning,
Mubsi

1 Like

Hi @Mubsi ,

Thanks for getting back. The issue was just the +1 was missing in the array slicing.

Yep, passed the course and received the certificate. :slight_smile:

Amrita

Hi @Mubsi,

I also encounter the same issue with wrong outputs

Error: Wrong output. for variable in position 0.
Error: Wrong output. for variable in position 1.

Could you help me see if my implementation is correct?
Lab ID okduwigi

Thanks!

Hi @cpcp,

I’m seeing that you are already passing all of the tests in your assignment. Glad you were able to figure out your mistake.

Happy learning,
Mubsi

Hi @Mubsi ,
Can you please take a look through my notebook , I am also getting this sort of error in 1 exercise , I have tried multiple times to figure out but didnot come to solution , kindly assists me to know where I am doing wrong as the deadline is drawing near

lab_id : wrenygmb

Thanks

Lab ID: tsranekg

Hi @Mubsi

I the above lab session, everything seems ok, but I get this…


Extracting (2, 2, 2) sub-volume

Error: Wrong shape. for variable 1.

Sampled Image:
z = 0
[[1. 2.]
[2. 4.]]
z = 1
[[2. 4.]
[4. 8.]]

Sampled Label:
class = 0
z = 0
[[1. 1.]
[1. 1.]]
z = 1
[[0. 0.]
[0. 0.]]
class = 1
z = 0
[[0. 0.]
[0. 0.]]
z = 1
[[1. 1.]
[1. 1.]]
2 Tests passed
1 Tests failed

The surprising bit is that the expected MRI image shows correctly. So, I’m not sure what I’m missing.

Please help urgently.

Thank you!

Hi @getjaidev,

You have ignored an important instruction:
Screenshot 2022-11-25 at 7.47.52 PM

You have not included number of classes.

When you’ll add that you’ll see your function will pass.

Cheers,
Mubsi

1 Like

Thanks @Mubsi. Worked!

Having similar issue

lab ID : ffsjlrqmsjxy

any suggestion?

Hi I got similar situation, can you help me solve?

ID: pysgojjpurgf

error messag:
Extracting (2, 2, 2) sub-volume

Error: Data-type mismatch.
Error: Wrong shape.
Error: Wrong output.

Hi @SSC13,

Welcome to the forum.

You probably missed this. I did, when i had this problem:

372670857fff9de1336abe9dba5801b2309bbf39

You might have not included number of classes.

Best Regards,
– Jaidev