Course 5 Week 2 Assignment 2 Exercise 5 - Emojify_V2

Hi,

I’m getting the following error. Not able to debug.

Test failed 
 Expected value 

 ['InputLayer', [(None, 4)], 0] 

 does not match the input value: 

 ['InputLayer', [(None, 10)], 0]
---------------------------------------------------------------------------
AssertionError                            Traceback (most recent call last)
<ipython-input-28-6d1e00d1aa10> in <module>
     22 
     23 
---> 24 Emojify_V2_test(Emojify_V2)

<ipython-input-28-6d1e00d1aa10> in Emojify_V2_test(target)
     19 
     20     expectedModel = [['InputLayer', [(None, 4)], 0], ['Embedding', (None, 4, 2), 30], ['LSTM', (None, 4, 128), 67072, (None, 4, 2), 'tanh', True], ['Dropout', (None, 4, 128), 0, 0.5], ['LSTM', (None, 128), 131584, (None, 4, 128), 'tanh', False], ['Dropout', (None, 128), 0, 0.5], ['Dense', (None, 5), 645, 'linear'], ['Activation', (None, 5), 0]]
---> 21     comparator(summary(model), expectedModel)
     22 
     23 

~/work/W2A2/test_utils.py in comparator(learner, instructor)
     21                   "\n\n does not match the input value: \n\n",
     22                   colored(f"{a}", "red"))
---> 23             raise AssertionError("Error in test")
     24     print(colored("All tests passed!", "green"))
     25 

AssertionError: Error in test

And I looked at the model.summary()

model = Emojify_V2((maxLen,), word_to_vec_map, word_to_index)
model.summary()

It appeared correct

Model: "functional_5"
_________________________________________________________________
Layer (type)                 Output Shape              Param #   
=================================================================
input_3 (InputLayer)         [(None, 10)]              0         
_________________________________________________________________
embedding_4 (Embedding)      (None, 10, 50)            20000050  
_________________________________________________________________
lstm_4 (LSTM)                (None, 10, 128)           91648     
_________________________________________________________________
dropout_4 (Dropout)          (None, 10, 128)           0         
_________________________________________________________________
lstm_5 (LSTM)                (None, 128)               131584    
_________________________________________________________________
dropout_5 (Dropout)          (None, 128)               0         
_________________________________________________________________
dense_2 (Dense)              (None, 5)                 645       
_________________________________________________________________
activation_2 (Activation)    (None, 5)                 0         
=================================================================
Total params: 20,223,927
Trainable params: 223,877
Non-trainable params: 20,000,050

I’m quite confused what’s going on here. Can anyone help out?

Another question - why do the layers start with input_3 under model summary? Shouldn’t it start with layer 1 and increment gradually?

Thanks

Huan

1 Like

I actually figured it out. I was VERY misled by the additional hit

raw_inputs = Input(shape=(maxLen,), dtype='int32')

I ended up using the wrong shape argument.

3 Likes

Don’t worry about the internal name(s) provided by tensorflow. The only thing that matters is the order of layers.

You can provide a name constructor argument to a keras layer to make the summary more informative.