Course 5 week 1 assignment 1 exercise 4 - AssertionError: Wrong values for a


When I run the cell that tests the lstm_forward function, I get “AssertionError: Wrong values for a”.
There isn’t a lot of coding involved, so I am having a hard time figuring what could have gone wrong. All test cases had passed for my implementation of lstm_cell_forward function.
The lines of code for lstm_forward function are as below.

{moderator edit: posting your code is not allowed by the Code of Conduct}
{Describing your code in minute detail is also not allowed}

Can someone please help me understand where I could be going wrong?


Hey Sayan - I think your solution is almost there, but c_next shouldn’t be pointing to a0 for multiple reasons, (1) you want to initialize c_next with zeros and a0 is the hidden state passed into the function, which might in the case of batching may not be zeros; (2) you want to make sure c_next has it’s own location in memory, which would mean to either copy a another variable or create a new one in order to satisfy the constraint. In this case (2) is the more important reason.

Hey Jack - Thanks a lot for pointing that out. Yeah on reading them, your points make a lot of sense. On initializing c_next with zeros, all the test cases have passed. Thanks again @Jack_Arenas !

Please do not post your code on the forum. That breaks the Code of Conduct.