Building an RNN with LSTM and after Padding and Masking I am getting a Failed to Convert Elements to Tensor Error

Hello I am currently building an RNN model that utilizes RNN. I have two embedded layers. I have padded my sequences with a custom value and I am trying to mask those sequences in the model creation. When I call model.fit on my train data I get this error:

Failed to convert elements of (None, None, 56) to Tensor. Consider casting elements to a supported type. See Module: tf.dtypes  |  TensorFlow v2.16.1 for supported TF dtypes.

Arguments received by BroadcastTo.call():
• x=tf.Tensor(shape=(None, 55, 1), dtype=bool)

I cannot make sense of this error. Before masking was introduced the model was able to fit on the data and now it cannot.

The only layer that has that shape is the output layer built Dense Layer:

dense_58 (Dense) │ (None, 55, 16) │ 528 │ lstm_59[0][0] │
├─────────────────────┼───────────────────┼────────────┼───────────────────┤
│ dense_59 (Dense) │ (None, 55, 1) │ 17 │ dense_58[0][0]

Hi @Richard_Garcia,

Sorry for the delay in response.
The error indicates a shape mismatch between (None, None, 56) and (None, 55, 1) might be mask getting broadcast incorrectly.I’d recommend you to check and ensure mask_zero=True in Embedding and return_sequences=True in LSTM. Also verify your y_train has shape (batch_size, sequence_length, 1) matching the output.

Hope this helps.Thank You.