I’m stuck on the Emojify assignment (Week 2, Assignment 2).
All the unit tests pass for both pretrained_embedding_layer and Emojify_V2. However, when I run:
model = Emojify_V2((maxLen,), word_to_vec_map, word_to_index)
model.summary()
I get the following error:
TypeError: Error converting shape to a TensorShape:
Dimension value must be integer or None or have an index method,
got value [‘I’, ‘am’, ‘so’, ‘excited’, ‘to’, ‘see’, ‘you’, ‘after’, ‘so’, ‘long’]
with type <class ‘list’>.
I verified that input_shape is (4,) (a tuple), and the graded tests all pass. I also checked my implementation, but I still get this error when creating the model.
Has anyone encountered this issue before, or is there something I might be overlooking?
That error means Keras is getting a list of words where it expects integers for the tensor shape. The string ['I', 'am', 'so', 'excited', ...] is actual sentence content leaking into the model-building step.
Check your Emojify_V2 function: it should only define the model graph (Input → embedding_layer → LSTM → Dropout → LSTM → Dropout → Dense → Activation → Model). It should not call sentences_to_indices inside it. The conversion from sentences to index arrays happens later, outside the model, right before model.fit().
If your Emojify_V2 code looks clean and doesn’t call sentences_to_indices, then:
- Check you haven’t edited anything outside the
# START CODE HERE / # END CODE HERE tags in that cell
- Do Kernel → Restart & Clear Output, then run all cells from the top
If you’re still stuck after both checks, share your Emojify_V2 code via DM so I can take a closer look.