Hey guys. I’ve been stuck in this error like literally more than a hour. And i really need a clue, since when i search up the error in this community, some people says that u should pay more attention to the n_H and n_W. Here is the picture below.
As you can see, this is the error. Is there anyone can help me further? Because i really can’t get the point about what that affect this error. Anything will help me thanks!
The error message shows that the shape of “a_slice_prev” is (3,2,4), and that of “weights” is (3,3,4). Apparently, the shape of “a_slice_prev” is not correct, simply because, “weights” comes from “W[:,:,:,c]”, which is one of parameters passed from a caller.
So, why the shape of “a_slice_prev” is (3,2,4) ?
“a_slice_prev” is a slice from “a_prev_pad”. As we do not touch the 3rd dimension, basically, you specified “vertical length” and horizontal length" to get a slice from a_prev_pad.
So, please check the size of this slice. The answer is “the same size as weights”.
You’ve mentioned that this happens because of the wieghts. So what you meant is try to fix the weights dimension?
No, you have a wrong size of a_slice_prev. That is what you need to check.
Oh okay, let me check first
Or maybe i’ll private chat with u…
I prefer “Open” discussion, simply because
- If other learners fall into the same problem, they can easily query and get hints without waiting someone in the community.
- Other mentors can easily take over or jump in.
I listed up typical error cases to use a sliding window.
Here is the step to get a slice, a_slice_prev, from a_prev_pad.
If we are in trouble, what we need to check are;
- f (filter size)
- Start position (which is calculated by using stride and loop indexes)
- Shape/Size of a slice (vert_start, vert_end, horiz_start, horiz_end)
I think it may not be a non-trivial task to do above.
The annoying case is like this.
Even if an algorithm to get a slice from a_pred_pad is OK, if there is an error to calculate a position, we are unable to get the right size of a slice. In the above case, we want to get (3,3,4) slice. But, there is no more data for the horizontal direction. Then, Python returns all remaining data which results in the shape of (3,2,4). I think this is your case.
I think i got it but then it also throws me the error of Wrong Z mean. Does this relate to this problem?
Oh nevermind. I fixed the Wrong Z mean simply because i iterate the wrong variable. Thank you so much for your help @anon57530071 !
Thank you for letting us know ! Please enjoy following lectures and assignments.