Course 4, week 1, first assignment, datatype mismatch, wrong shape, conv_single_step function

Hi, in the first part of assignment 1, in “conv_single_step” I encounter with ‘datatype mismatch’ and ‘wrong shape’ errors ( 1 test passed, 2 failed) , I can’t find where the problem is. please someone help me.
I used np.multiply -->np.sum then astype function to cast b before adding to the Z, but I just encounter with the errors!

  1. Do not post your code on the Forums. That breaks the course Honor Code. Please edit your post and remove your code. Thank you.
  2. Check whether you have the order of the arguments correct in the multiply operation. This is often the cause of “wrong shape” errors.

Sorry about that.
I’m not sure I understand what you said! both of W and a_slice_prev are in the same shape and in doesn’t matter which one be located firstly in np.mutiply because it’s elementwise product.

Good point, sorry that was my mistake. I was reading the wrong line of the notebook comments.

Try using np.float(b) instead of astype.

If that doesn’t help, then:

  • use “Kernel” and “Restart and clear output”
  • then use “Cell” and Run All.
1 Like

Also, have you updated your Notebook to the current version?
It was updated on May 21.

I’m sorry but I did everything that you said, I still have the same problem!
the only detail that I haven’t mentioned is setting axis=None and Keepdims=True, also I think there isn’t any problem with them.
it’s some simple lines of codes but I have no idea where the problem could have been.

don’t you have any another guideline?!

No, sorry, I don’t have any other suggestions.

I do have one thought. Are you sure that “axis=None” and “Keepdims= True” are correct?

Thank you, it helps alot