Error in test Week 1 Assignment 3

Hello,

I did the notebook correctly and was graded 100/100. But upon downloading to my own laptop to run, there are issues from the UNIT Test section where AssertionError: Error in test is shown.

For example, one of the output is:

Test failed at index 1
Expected value

[‘SlicingOpLambda’, (None, 90), 0]

does not match the input value:

[‘TensorFlowOpLayer’, [(None, 90)], 0]

AssertionError Traceback (most recent call last)
in
1 # UNIT TEST
2 output = summary(model)
----> 3 comparator(output, djmodel_out)

~/Desktop/Python/Deep Learning Specialisation/5-Sequence Models/test_utils2.py in comparator(learner, instructor)
26 “\n\n does not match the input value: \n\n”,
27 colored(f"{a}", “red”))
—> 28 raise AssertionError(“Error in test”)
29 print(colored(“All tests passed!”, “green”))
30

AssertionError: Error in test

Test failed at index 5
Expected value

[‘TFOpLambda’, (None,), 0]

does not match the input value:

[‘TensorFlowOpLayer’, [(None,)], 0]

AssertionError Traceback (most recent call last)
in
1 # UNIT TEST
2 inference_summary = summary(inference_model)
----> 3 comparator(inference_summary, music_inference_model_out)

~/Desktop/Python/Deep Learning Specialisation/5-Sequence Models/test_utils2.py in comparator(learner, instructor)
26 “\n\n does not match the input value: \n\n”,
27 colored(f"{a}", “red”))
—> 28 raise AssertionError(“Error in test”)
29 print(colored(“All tests passed!”, “green”))
30

AssertionError: Error in test

This cause the final np.argmax(results[12]) to differ alot from the original answers. Please help

1 Like

Are you still having a problem with this?

Yes, please help with this problem. I did not change anything from the notebook i submitted to Coursera

Sorry, I don’t know anything about running the notebooks locally on your own computer.

This is likely due to the versions of the libraries (Python, Tensorflow, Keras, something else) being different from the official one in Coursera so that the same operation got renamed (in the context of what happens behind the scenes inside a Keras Model) from TensorFlowOpLayer to TFOpLambda or SlicingOpLambda from one version to another.

The problem is not in the notebook, but in the environment.


AssertionError Traceback (most recent call last)
in
1 # UNIT TEST
2 inference_summary = summary(inference_model)
----> 3 comparator(inference_summary, music_inference_model_out)

~/work/W1A3/test_utils.py in comparator(learner, instructor)
16 def comparator(learner, instructor):
17 if len(learner) != len(instructor):
—> 18 raise AssertionError(“Error in test. The lists contain a different number of elements”)
19 for index, a in enumerate(instructor):
20 b = learner[index]

AssertionError: Error in test. The lists contain a different number of elements

i have got this error anad not able to resolve it and i’ve restareted and run all cells quite a several times so pls help in this

I think you are better to actually compare your model and expected output.
As you see, you can get the summary of your model with;

summary(inference_model)

Then, you can also get an expected output like this;

music_inference_model_out

Output will be like this…

[['InputLayer', [(None, 1, 90)], 0],
 ['InputLayer', [(None, 64)], 0],
 ['InputLayer', [(None, 64)], 0],
 ['LSTM',
  [(None, 64), (None, 64), (None, 64)],
  39680,
  [(None, 1, 90), (None, 64), (None, 64)],
  'tanh'],
 ['Dense', (None, 90), 5850, 'softmax'],
 ['TensorFlowOpLayer', [(None,)], 0],
 ['TensorFlowOpLayer', [(None, 90)], 0],
 ['RepeatVector', (None, 1, 90), 0, 1],
 ['TensorFlowOpLayer', [(None,)], 0],
  :
  :

Now, you can check which layer is not created correctly.

And, this single cell can reset LSTM status. Do not need to restart everything.

LSTM_cell = LSTM(n_a, return_state = True)

This will be the most “executed” cell during debugging… :slight_smile: