Course 5 Week 3 Assignment 1 modelf

Hello, in the routine modelf, how do we represent s_t-1 and c_t-1 ??

"
Iterate for 𝑑=0,β‹―,π‘‡π‘¦βˆ’1t=0,β‹―,Tyβˆ’1:

  1. Call one_step_attention(), passing in the sequence of hidden states [π‘ŽβŸ¨1⟩,π‘ŽβŸ¨2⟩,…,π‘ŽβŸ¨π‘‡π‘₯⟩][a⟨1⟩,a⟨2⟩,…,a⟨Tx⟩] from the pre-attention bi-directional LSTM, and the previous hidden state s<tβˆ’1> from the post-attention LSTM to calculate the context vector π‘π‘œπ‘›π‘‘π‘’π‘₯𝑑<𝑑>context.
    Give π‘π‘œπ‘›π‘‘π‘’π‘₯𝑑<𝑑>context to the post-attention LSTM cell.
  • Remember to pass in the previous hidden-state s⟨tβˆ’1⟩ and cell-states c⟨tβˆ’1⟩ of this LSTM
    "

Those are the current s and c variables.
They’re updated as the β€œnext” values when the function returns.

When I try s, I get the following error on one_step_attention when I run the unit test:

Maybe the problem is with how you’re computing s_prev in one_step_attention().

@TMosh n one_step_attention, i compute s_prev as repeator(s_prev) which gives it the same shape as a. that’s what is the requirement. I i think that was ok

That seems OK.
{remainder of reply edited}

sent the notebook via DM…

I sent you a reply message.

For other students who find this thread, check that you’re using the correct function parameters for the units and states.

I am also getting this error. How did you solve this issue. According to the error the problem is with the concatenation step. Could you please help me?

Error:

See this line of code in one_step_attention()
image

Try using parenthesis instead of square brackets.

The square brackets make it a list, but the parenthesis make it a tuple. It might help.

2 Likes

I am getting the same error and I can’t figure out what could be wrong with my units and states parameters. I have passed the state as returned from the bidirectional lstm and the post-attention state that was initialized earlier and updated by the post_activation_lstm layer.

What am I missing?

There are at least two different errors discussed in this thread.
Which β€œsame error” do you have? Please post a screen capture image.

image

Should be an array (using square brackets) not a tuple (using parenthesis).

See if that helps.

I tried, still getting the same error.

Please post a new image of the error that shows your call to Bidirectional(…).

Also, did you save your notebook and the re-run the one_step_attention() cell, so that your changes were included?

The error does not show my call to Bidirectional(…), but here is the whole thing, in two images (sorry, my laptop screen is small)


I did re-run all the cells and the error is still there.

In one_step_attention(), did you use s_prev = repeator(s_prev)?

I asked to see your call to Bidirectional(…) for a reason.

I wanted to see how you are setting the β€œa” variable.