Week 1, Assignment 1: AssertionError: Wrong values for y_pred

Hi,

I am getting below error while running rnn_forward function

a[4][1] =
[-0.99999375 0.77911235 -0.99861469 -0.99833267]
a.shape =
(5, 10, 4)
y_pred[1][3] =
[0.96251083 0.79560373 0.86224861 0.11118257]
y_pred.shape =
(2, 10, 4)
caches[1][1][3] =
[-1.1425182 -0.34934272 -0.20889423 0.58662319]
len(caches) =
2

AssertionError Traceback (most recent call last)
in
18
19 #UNIT TEST
—> 20 rnn_forward_test(rnn_forward)

~/work/W1A1/public_tests.py in rnn_forward_test(target)
76
77 assert np.allclose(a[5, 2, 2:6], [0.99999291, 0.99332189, 0.9921928, 0.99503445]), “Wrong values for a”
—> 78 assert np.allclose(y_pred[2, 1, 1: 5], [0.19428, 0.14292, 0.24993, 0.00119], atol=1e-4), “Wrong values for y_pred”
79 assert np.allclose(caches[1], x_tmp), f"Fail check: cache[1] != x_tmp"
80

AssertionError: Wrong values for y_pred

This error message means that your outputs don’t contain the expected values. Check the way you get y_pred.

There was an issue in the y_pred formula in rnn_cell_forward. I have corrected it and it is working now.

Thanks a lot

1 Like

Hi,
I am having same issue for running rnn_forward_test(rnn_forward).
rnn_cell_forward is working fine, all tests passed.

For RNN forward pass, i get below results along with the error.
a[4][1] =
[-0.99999375 -0.994001 -0.99999997 -0.99999767]
a.shape =
(5, 10, 4)
y_pred[1][3] =
[0.79560373 0.89134676 0.06430944 0.66923503]
y_pred.shape =
(2, 10, 4)
caches[1][1][3] =
[-1.1425182 -0.34934272 -0.20889423 0.58662319]
len(caches) =
2

AssertionError Traceback (most recent call last)
in
18
19 #UNIT TEST
—> 20 rnn_forward_test(rnn_forward)

~/work/W1A1/public_tests.py in rnn_forward_test(target)
75 assert len(caches[0]) == T_x, f"len(cache) must be T_x = {T_x}"
76
—> 77 assert np.allclose(a[5, 2, 2:6], [0.99999291, 0.99332189, 0.9921928, 0.99503445]), “Wrong values for a”
78 assert np.allclose(y_pred[2, 1, 1: 5], [0.19428, 0.14292, 0.24993, 0.00119], atol=1e-4), “Wrong values for y_pred”
79 assert np.allclose(caches[1], x_tmp), f"Fail check: cache[1] != x_tmp"

AssertionError: Wrong values for a

I see a_next.shape is [7,8]
is there any issue with the way of appending cache? I use .append…

Hi Rasitha,

Where was the error in y_pred formula? Looks like I will have the same problem. But I am not able to figure it out.

I use softmax and np.dot for (Wya , a_next) + by

Thanks,
Sowmya

Hi @rasitharaghu , & @Sowmyyav

Check that the a_next is calculated correctly in rnn_cell_forward() and the correct parameters are passed to rnn_cell_forward() when it is called at rnn_forward()

1 Like

Many Thanks Kic,

I was sending a0 instead of a_next. Now its working.

Hi @Sowmyyav

Great to hear it is working now. Thanks

In my case I used a_prev for calculating yt_pred in rnn_cell_forward function. Looks like you have provided the correct value. Check the value of a_next.

You are right Rasitha, I was giving a0 instead of a_next to the function.
Its working now. Many thanks.
Tá an t-eolas atá le fáil sa ríomhphost seo faoi iontaoibh agus tá sé ceaptha le haghaidh aird an fhaighteora bheartaithe/na bhfaighteoirí beartaithe amháin. Más rud é go bhfuair tú an ríomhphost seo go hearráideach, ná húsáid agus ná tarchuir é ar mhaithe le haon chuspóir, le do thoil; ina áit sin cuir ar an eolas muid láithreach agus scrios gach cóip den ríomhphost seo ó do chóra(i)s ríomhaireachta. Ach amháin sa chás gur comhaontaíodh a leithéid go sonrach ag ár n-ionadaí údaraithe, is le húdar an ríomhphoist amháin na tuairimí a chuirtear in iúl ann, agus ní léiríonn siad tuairim ná ní chuireann siad ceangal ar aon chaoi eile ar Institiúid Teicneolaíochta Bhaile Átha Luain. Déan teagmháil le administrator@ait.ie nó cuir glao ar 090 6468000. The information contained in this email is confidential and is designated solely for the attention of the intended recipient(s). If you have received this email in error, please do not use or transmit it for any purpose but rather notify us immediately and delete all copies of this email from your computer system(s). Unless otherwise specifically agreed by our authorised representative, the views expressed in this email are those of the author only and shall not represent the view of or otherwise bind Athlone Institute of Technology. Contact administrator@ait.ie or telephone 090 6468000.

Hi, I have the same problem and I have checked all the comments. What else it can be?
the cell function (rnn_cell_forward) has already been validated so it shouldn’t be there the problem.
a and the dimensions are correct. ¿?

This is the trace:
a[4][1] =
[-0.99999375 0.77911235 -0.99861469 -0.99833267]
a.shape =
(5, 10, 4)
y_pred[1][3] =
[0.96251083 0.79560373 0.86224861 0.11118257]
y_pred.shape =
(2, 10, 4)
caches[1][1][3] =
[-1.1425182 -0.34934272 -0.20889423 0.58662319]
len(caches) =
2

AssertionError Traceback (most recent call last)
in
18
19 #UNIT TEST
—> 20 rnn_forward_test(rnn_forward)

~/work/W1A1/public_tests.py in rnn_forward_test(target)
76
77 assert np.allclose(a[5, 2, 2:6], [0.99999291, 0.99332189, 0.9921928, 0.99503445]), “Wrong values for a”
—> 78 assert np.allclose(y_pred[2, 1, 1: 5], [0.19428, 0.14292, 0.24993, 0.00119], atol=1e-4), “Wrong values for y_pred”
79 assert np.allclose(caches[1], x_tmp), f"Fail check: cache[1] != x_tmp"
80

AssertionError: Wrong values for y_pred

1 Like

I found the error were I was not looking. The single cell function passed the tests but had an error. Solved now.

1 Like

Hi @Edu4rd

Great to hear you have got the problem solved. Thanks

1 Like

I’ve got the same y_pred[1][3] as what you’ve got and I couldn’t solve the problem before seeing your comments. Thanks for your remind of the single cell function.