C5_W1_A1 lstm_cell_forward c_next

I got the error “wrong values for c_next”. My code follows the LSTM formula provided in lecture to sum up two element-wise products: one being the product of forget gate and c_prev, the other being the product of update gate and candidate c value. My code uses np.multiply to do element-wise multiplication. I would appreciate it if any hint is available. Thanks.

1 Like

Hi @wchung

Could you post that section of the code in a DM to me, I will have a look for you.

Hi @wchung ,

The problem is in the calculation for a_next . Here, you need to use tanh() to compress c_next to within the (-1,1) range of values, and then multiplying it by ot.

Oh, I was following the formula shown on slide titled “LSTM in pictures” to code a_next. That formula does not include tanh. Now I recall that there is a correction for the same calculation on the previous slide. Thanks.