[solved] C3W3_Assignment - trouble with the Embedding layer

[Edit - this happened because I forgot to convert the 0-4 label to 0-1. So yes, the label differences in section 5 do matter! :slight_smile: Then, I initialise my last Dense layer to have only 1 neuron, and everything worked. I am leaving this here, just in case someone else makes the same mistake]

Hi,

I had this with the previous week’s assignment as well. It seems that I am doing something wrong, but I can’t figure out what.

So, in section 25, there is this line:

tf.keras.layers.Embedding(vocab_size+1, embedding_dim, input_length=maxlen, weights=[embeddings_matrix], trainable=False),

This directly comes from the input arguments, I am OK with this.

When displaying the model summary, I can see what type of output it supposed to generate:

embedding_1 (Embedding)     (None, 16, 100)           12829400  

But, when I run the code, I am getting an error, because the output of this layer is not the correct shape:

ValueError: Shapes (32,) and (32, 16, 100) are incompatible

Everything else seems to run fine in the assignment, and I am getting the expected outputs (except in section 5, where the label numbers are different, but that shouldn’t matter…)

So, can someone give me a hint to resolve this?

Thanks for keeping this issue and also keeping the solution in the edit
This will surely help the fellow learners