Week1 - Assignment 3 Exercise 1 - dj Model output incorrect

In Assignment_3 Exercise_1, my model summary output (see below) is different from the expected. It seems I have more Reshape nodes in comparison to the expected output. I tried both:
x = Reshape((1, n_values))(x) or x = Reshape(x)

[[‘InputLayer’, [(None, 30, 90)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘InputLayer’, [(None, 64)], 0], [‘InputLayer’, [(None, 64)], 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘LSTM’, [(None, 64), (None, 64), (None, 64)], 39680, [(None, 1, 90), (None, 64), (None, 64)], ‘tanh’], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘TensorFlowOpLayer’, [(None, 90)], 0], [‘Reshape’, (None, 1, 90), 0], [‘Dense’, (None, 90), 5850, ‘softmax’]]

I

1 Like

The correct way to implement your second choice there would be:

x = reshaper(x)

Because the point is that reshaper is a predefined (instantiated) function that they created for you. But that would then make it equivalent to the first (leftmost) version. Which actually looks correct to me. Are you sure this is not another “out of sync” situation?

But perhaps the problem is elsewhere. The way your summary is formatted makes it essentially impossible to interpret. Here’s a better way:

print("Generated model:")
for index, a in enumerate(summary(model)):
    print(f"layer {index}: {a}")
print("Expected model:")
for index, a in enumerate(djmodel_out):
    print(f"layer {index}: {a}")
1 Like

Thanks, it works now. I should use the reshaper passed as an argument in the djmodel(…) instead of creating Reshaper object in the loop.

1 Like

Hi,

I finished all the required tasks/steps for Assignment 3. All seems fine. After submitting it, I still see it failed with 0/100 score. Do you have a clue or suggestion? Thanks

What is the output that it shows under “Show grader output”?

Never mind, it shows “Passed 100%” now. I have a debugging cell removed. Thanks.

Whew! Glad to hear you found the solution.