Folks:
At assignment 1 of Wk 3 (course 5) “Neural_machine_translation_with_attention_v4a”, my code failed at Unit Test 2. I’m unable to debug it, even after I’ve search past posts. Please help me to find out what’s wrong with my code ?
Here’s the code, including the original:
# UNQ_C1 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)
# GRADED FUNCTION: one_step_attention
{mentor edit: code removed}
# UNIT TEST
def one_step_attention_test(target):
....
## Passed Unit Test 1
All tests passed!
n_a = 32 # number of units for the pre-attention, bi-directional LSTM's hidden state 'a'
n_s = 64 # number of units for the post-attention LSTM's hidden state "s"
# Please note, this is the post attention LSTM cell.
post_activation_LSTM_cell = LSTM(n_s, return_state = True) # Please do not modify this global variable.
output_layer = Dense(len(machine_vocab), activation=softmax)
# UNQ_C2 (UNIQUE CELL IDENTIFIER, DO NOT EDIT)
# GRADED FUNCTION: model
def modelf(Tx, Ty, n_a, n_s, human_vocab_size, machine_vocab_size):
{mentor edit: code removed}
return model
# UNIT TEST
from test_utils import *
def modelf_test(target):
m = 10
Tx = 30
...
Blockquote
my code failed this Unit test with the following err msg :
[[‘InputLayer’, [(None, 30, 37)], 0], [‘Bidirectional’, (None, 30, 64), 17920], [‘Dense’, (None, 30, 1), 65, ‘relu’], [‘Activation’, (None, 30, 1), 0], [‘Dot’, (None, 1, 64), 0], [‘InputLayer’, [(None, 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’]]
Test failed at layer: 1
Expected value
[‘InputLayer’, [(None, 64)], 0]
does not match the input value:
[‘Bidirectional’, (None, 30, 64), 17920]
AssertionError Traceback (most recent call last)
in
34
35
—> 36 modelf_test(modelf)
in modelf_test(target)
31 assert len(model.outputs) == 10, f"Wrong output shape. Expected 10 != {len(model.outputs)}"
32
—> 33 comparator(summary(model), expected_summary)
34
35
~/work/W3A1/test_utils.py in comparator(learner, instructor)
25 “\n\n does not match the input value: \n\n”,
26 colored(f"{a}", “red”))
—> 27 raise AssertionError(“Error in test”)
28 layer += 1
29 print(colored(“All tests passed!”, “green”))
AssertionError: Error in test
Blockquote