LSTM model - shape are incompatible or logits/labels error

Hi,
I am working on NLP LSTM model but getting this error

input sentence : [123 88 170 221 132 52 105 32 211 91 126 211 24 221 134 154 221 162
215 80 144 101 61 136 68 133 40 200 133 40 218 131 139 199 124 74
184 92 213 185 221 221 221 221 221 221 221 221 221 221]
output sentece label: [ 7 7 7 7 0 7 6 2 7 5 1 7 7 7 7 7 7 7 7 10 7 7 7 7
3 8 7 3 8 7 7 7 7 7 7 7 7 6 2 7 7 7 7 7 7 7 7 7
7 7]

Both input and output are of length 50

If I use loss function as “categorical_crossentropy” , i get this error:
ValueError: Shapes (None, 50) and (None, 11) are incompatible

If I use loss function as “sparse_categorical_crossentropy” , i get this error:
logits and labels must have the same first dimension, got logits shape [13,11] and labels shape [650]
[[{{node sparse_categorical_crossentropy/SparseSoftmaxCrossEntropyWithLogits/SparseSoftmaxCrossEntropyWithLogits}}]]

I tried adding input shape as first layer but still no luck
tf.keras.layers.Input(shape=(max_len,))

Can anyone help , how to solve this problem.

Please move this topic to the right subcategory. Here’s the community user guide to get started.

If your question is course related, don’t forget to remove code from your post. It’s okay to share stacktrace though.

ok removed the code.

Please click my name and message your notebook as an attachment.

Never mind. Solved it.

Hi, I want to learn unsupervised learning models using Tensorflow 2.0 in coursera. There is no way I can create new topic these days, don’t know why. I have done multiple courses in Coursera related to ML/AI. So, replying to one of my old question, forgive me. Would like to know if any course available for Tensorflow2.0 unsupervised learning models.

Try this