C4W1-Assignment - sampling_decode passes unit test, but doesn't output correct answers

(Solution code removed by staff, as posting it publicly is against the honour code)

sampling_decode passes all unit tests, but as you can see from the output of the sample, it doesn’t quite give the correct answer as it should just be ‘Ich liebe Sprachen.’ and not '‘Ich liebe Sprachen.ich ich.’. It’s odd as it gets the ‘I am hungry’ greedy_decode_test correct, but it goes into an infinite loop on ‘You are almost done with the assignment!’ greedy_decode_test.

1 Like

Hi @dinonaut,

Can you share your lab ID with me ? In the assignment, when you click the top right “Help” button, a panel will open and your lab ID will be shown at the bottom.

I shall take a look.

When you reply back, kindly tag me in the post so that I’m notified.


@Mubsi I sent you a message with the lab ID.


Hi @dinonaut,

I’m looking into it as we speak.

I encountered the same problem. Is there any update?

I had the same problem.
My mistake was using global variables instead of method parameters.

I used global variables VOCAB_FILE, VOCAB_DIR in tokenize and detokenize methods instead of method parameters vocab_dir, vocab_file.

I´m having this same issue, where should I change vocab_dir and vocab_file?

Hi @Mubsi , I’m running into the same issue that @dinonaut mentioned above (my lab id: cfhvnojp ). Could you give me any pointers on how to go about fixing this issue? Thanks.

I solved it by paying close attention to the implementation for this line:

# get log probabilities from the last token output

Hi @Mubsi , I’ve followed the suggestions from this and other posts but still having this same issue, surely something Im not seeing. Could you please take a look at my notebook? lab_id = koamttlbqvqr