Can anybody tell me how to use mask argument in LSTM cell

I have a X_train padded sequence of shape (1400, 17640) and separate mask array of shape (1400, 17640) of type boolean what I want to create

layer1 = Input(shape=(X_train.shape[1], 1))

layer2 = Dense(64, name='layer2', mask=[need to provide mask here])(layer1)

output = Dense(10, activation='softmax', name='output')(layer2)

can you tell me how to do that if I already have pre-computed padded sequence and mask Boolean array of same size?

Hi @AKASH_KUMAR ,

Here’s how you can achieve this:

  1. Define a Custom Layer for Masking: Create a custom Keras layer that applies the mask to the input.
  2. Integrate the Masked Input with the Model: Use the custom masking layer in your model definition.

For better understanding , Kindly refer this official documentation.

Thank You .