Dinosaur Island-Character-Level Language Modeling

I have a problem with the programming exercise of week 1 “Dinosaur Island-Character-Level Language Modeling” I have an error at the output that is :slight_smile:

Code Cell UNQ_C1: Function ‘clip’ is correct.
Code Cell UNQ_C2: Function ‘sample’ is correct.
Code Cell UNQ_C3: Unexpected error (KeyError(‘da_next’)) occurred during function check. We expected function optimize to return Test 3 failed. Please check that this function is defined properly.
Code Cell UNQ_C4: Function ‘model’ is correct.
If you see many functions being marked as incorrect, try to trace back your steps & identify if there is an incorrect function that is being used in other steps.
This dependency may be the cause of the errors.

and function of optimizing is :slight_smile:

{moderator edit - solution code removed}

That code looks the same as mine. One thing to check: I’m pretty sure that the notebooks here in Course 5 do not do an automatic “Save” for your when you click “Submit Assignment”. So it’s possible that the grader is seeing an older version of the code. Try manually clicking “Save” and then submit again. Also are you sure that you pass the tests in the notebook (although that is never a guarantee of complete correctness)? Check your results for the “clip” function as well, since that is called here.

1 Like

Actually the bug here was probably in the clip function itself, but the grader only reports it as a bug in optimize. Here’s a thread which discusses this in more detail.