C5W3 Machine Translation: can't seem to set up model correctly

Hi everyone,
i’m really struggling with Exercise 2 in Neural Machine Translation.
I believe I did everything right, but I always get this error:

I’ve really tried everything I could imagine but can’t figure out - and my subscription is running out… Could I get some help with this?

Hello @Julia_Suter, as mentor, we can provide you some suggestion on how you can debug it yourself. Here is how you can make use of the error traceback:

The error is triggered because the check in (2) returned a False, and if you trace back, you will see that through (3), (4), and (5), we are actually comparing the length of the lists of expected_summary and summary(model). You can see every single expected layers in the expected_summary, and you the print(summary(model)) line should have printed what it has. Then you can compare the two by eye, and see what’s extra or missed which is the lead. With the lead, you can go back to your code and find out why that happened.

Good luck!
Raymond

Hi, thanks a lot for the input. My model gives the following output:

[['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, 1), 129, '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'], ['Dense', (None, 11), 715, 'softmax']]

So that means that one dense layer in the middle is missing and the one I have is wrong. Unfortunately, I can’t figure out how to adapt my code to get to the right output.

It looks like it’s using densor2 instead of densor1. Is it by any chance possible that my code from the previous exercise is faulty although it passed all the tests? I’m really a bit lost.

Hello @Julia_Suter,

Very likely has something to do with your previous exercise, because the missing Dense should come from there, but doesn’t the exercise instruct us to use both densors? :slight_smile:

image

Cheers,
Raymond

Hi Raymond,

Thanks so much for the tip, and sorry for the late reply.
Unfortunately, I still had no luck with making it work. I did set the densors in the code you mentioned above, and I think everything is correct. However, I still get the same issues with the model.

{code removed by mentor}

I’m really quite lost, and I’ve already had to pay 1 month more subscription because of this issue. What can I do to make this work? Is there potentially an issue with the grader?

Hello @Julia_Suter

I hope we can spend 1 minute on the comments provided by the exercise again:

    # Use densor1 to propagate concat through a small fully-connected neural network to compute the "intermediate energies" variable e. (≈1 lines)
    e = 
    # Use densor2 to propagate e through a small fully-connected neural network to compute the "energies" variable energies. (≈1 lines)
    energies = 

@Julia_Suter,

  1. we propagate what through densor1? What did you propagate there?
  2. we propagate what through densor2? What did you propagate there?

We are building a network according to the lab’s instructions, so the answers are in the comments. You made a right choice and a wrong choice.

@Julia_Suter, when we build a model in other occasions, if we have used a layer (let’s say a dense layer), but it does not show up in the model’s summary, it can mean that the output of that layer is not connected to any part of the model. Because the output of that layer is not used, then from the angle of optimization, the model doesn’t need it at all. Why still spend time on computing that layer when that layer’s output is not used anywhere?

Cheers,
Raymond

PS: I am removing your code since we can’t share it in this community.