Masking layer for RNN

Is there any function similar to keras.layers.Masking which masks the rows of timeseries data which is filled with an specific value (e.g. padded with zero)?

By slicing perhaps.

t[ : , a:b , : ]=0

Thanks for your answer. in this way, I need to have the start and end index of the non padded values, isn’t there any other more straightforward way like Masking layer in keras?

one thing more, by slicing we feed the matrix with different shapes into RNN, is this acceptable in pytorch? (e.g. data[0].size() could be (timesteps=100, features=20) and data[10].size() could be (timesteps=34, features=20))

  1. Idk how r you going to set values to zero if u don’t know where the values are. You can check torch.masked_select, but i’m quite sure u need to know what to mask. Just curious, are you doing ASR?

  2. u have to pad them into a bigger tensor, u can’t even feed it into rnn if u don’t pad

Ok, Thanks for the clarifications :slight_smile: . No I am not doing ASR.

Use this


Were you able to find a solution for this?