Having issues with Neural Machine Translation Lab (modelf functin)

Hello, I’m having a problem with the modelf function and getting that to work. I followed all the steps there but just can’t get it to run. I think the critical pieces of my code are:

{moderator edit: code removed}

I’m not sure what I’m doing wrong here. Thanks! Also sorry if I was not supposed to post this code here like this.

Please click my name and message your notebook as an attachment.

Posting code in a public topic is discouraged and can get your account suspended. It’s okay to share stacktrace on a public post and send code to a mentor via direct message. Here’s the community user guide to get started.

I’m very sorry about posting the code like that. won’t do that again.

Hints:

  1. There’s a problem with one_step_attention in the 1st line of code s_prev = .... Remember that there’s a difference between creating a new instance every time vs sharing layers.
  2. See in the previous code cell the shared global variables you’ve created.

I don’t understand how I’m supposed to get the previous hidden state s_prev in this code then. I though that since we are looping through, s should be updated each time

The model summary from my modelf function that I’m getting looks like this:

[[‘InputLayer’, [(None, 30, 37)], 0],
[‘InputLayer’, [(None, 64)], 0],
[‘Bidirectional’, (None, 30, 64), 17920],
[‘RepeatVector’, (None, 30, 64), 0, 30],
[‘Concatenate’, (None, 30, 128), 0],
[‘Dense’, (None, 30, 10), 1290, ‘tanh’],
[‘Dense’, (None, 30, 1), 11, ‘relu’],
[‘Activation’, (None, 30, 1), 0],
[‘Dot’, (None, 1, 64), 0],
[‘InputLayer’, [(None, 64)], 0],
[‘LSTM’,
[(None, 64), (None, 64), (None, 64)],
33024,
[(None, 1, 64), (None, 64), (None, 64)],
‘tanh’],
[‘RepeatVector’, (None, 30, 64), 0, 30],
[‘Concatenate’, (None, 30, 128), 0],
[‘RepeatVector’, (None, 30, 64), 0, 30],
[‘Concatenate’, (None, 30, 128), 0],
[‘RepeatVector’, (None, 30, 64), 0, 30],
[‘Concatenate’, (None, 30, 128), 0],
[‘RepeatVector’, (None, 30, 64), 0, 30],
[‘Concatenate’, (None, 30, 128), 0],
[‘RepeatVector’, (None, 30, 64), 0, 30],
[‘Concatenate’, (None, 30, 128), 0],
[‘RepeatVector’, (None, 30, 64), 0, 30],
[‘Concatenate’, (None, 30, 128), 0],
[‘RepeatVector’, (None, 30, 64), 0, 30],
[‘Concatenate’, (None, 30, 128), 0],
[‘RepeatVector’, (None, 30, 64), 0, 30],
[‘Concatenate’, (None, 30, 128), 0],
[‘RepeatVector’, (None, 30, 64), 0, 30],
[‘Concatenate’, (None, 30, 128), 0],
[‘Dense’, (None, 11), 715, ‘softmax’]]

Has anyone else seen something like this when they ran their code? and where this is coming from?

Expanding on this reply:
In your implementation, s_prev and concat are created with new layers for every invocation of one_step_attention. Use the global variables you’ve defined one code cell above the function.

1 Like

Ok I got it to work. Realizing that I did not use the shared layer variables. I thought the problem was in my modelf function but it was really in how I implemented the one_step_attention function. did not initially understand you but I got things to pass. thank you so much ! and sorry for being difficult.

No worries.