Hi ,
i tried lot to solve this ,but nt able to understand.
please help to resolve this issue.
Thanks
Hi ,
i tried lot to solve this ,but nt able to understand.
please help to resolve this issue.
Thanks
The error says that Z
has fewer dimensions than 4 and hence the problem. I’m using a more recent version of numpy which explains the detailed error message:
>>> import numpy as np
>>> a = np.ones((2,3))
>>> a.shape
(2, 3)
>>> # see number of dimensions
>>> a.ndim
2
>>> # This is ok
>>> a[1, 2] = 100
>>> a
array([[ 1., 1., 1.],
[ 1., 1., 100.]])
>>> # This is not ok
>>> a[1, 2, 3] = 100
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
IndexError: too many indices for array: array is 2-dimensional, but 3 were indexed
>>>
2 more hints:
Z.ndim
should be 4.conv_single_step
I added print statements to my conv_forward
code to see what is going on and here’s what I get when I run the tests for conv_forward
:
stride 2 pad 1
New dimensions = 3 by 4
Shape Z = (2, 3, 4, 8)
Shape A_prev_pad = (2, 7, 9, 4)
Z[0,0,0,0] = -2.651123629553914
Z[1,2,3,7] = 0.4427056509973153
Z's mean =
0.5511276474566768
Z[0,2,1] =
[-2.17796037 8.07171329 -0.5772704 3.36286738 4.48113645 -2.89198428
10.99288867 3.03171932]
cache_conv[0][1][2][3] =
[-1.1191154 1.9560789 -0.3264995 -1.34267579]
First Test: All tests passed!
stride 1 pad 3
New dimensions = 9 by 11
Shape Z = (2, 9, 11, 8)
Shape A_prev_pad = (2, 11, 13, 4)
Z[0,0,0,0] = 1.4306973717089302
Z[1,8,10,7] = -0.6695027738712113
stride 2 pad 0
New dimensions = 2 by 3
Shape Z = (2, 2, 3, 8)
Shape A_prev_pad = (2, 5, 7, 4)
Z[0,0,0,0] = 8.430161780192094
Z[1,1,2,7] = -0.2674960203423288
stride 1 pad 6
New dimensions = 13 by 15
Shape Z = (2, 13, 15, 8)
Shape A_prev_pad = (2, 17, 19, 4)
Z[0,0,0,0] = 0.5619706599772282
Z[1,12,14,7] = -1.622674822605305
Second Test: All tests passed!
hi ,
I have a doubt about the questions asked
because in the next question they asked again about padding to A_prev
please clear my query
thank you verymuch
Suman Vemula
Yes, absolutely. The whole point of those formulas is that you need to take all those values into account in order to figure out the output size of a convolution: the input size, the filter size, the stride and the padding.