Variable-length sequence for sequence auto-encoder

I am trying to build a sequence for an autoencoder sequence with variable-length sequences of floating points. I was wondering which of these implementations is correct:

seq_autoenc = Sequential()
seq_autoenc.add(Masking(mask_value=mask_value, input_shape=(None, inp_dim)))
seq_autoenc.add(LSTM(enc_len, return_sequences=True, implementation=implementation, name='encoder'))
seq_autoenc.add(LSTM(inp_dim, return_sequences=True, implementation=implementation, name='decoder'))

or

seq_autoenc = Sequential()
seq_autoenc.add(Masking(mask_value=mask_value, input_shape=(inp_max_len, inp_dim)))
seq_autoenc.add(cell(enc_len, implementation=implementation, name='encoder'))
seq_autoenc.add(RepeatVector(inp_max_len, name='repeater'))
seq_autoenc.add(cell(inp_dim, return_sequences=True, implementation=implementation, name='decoder'))

The problem with the last code is that the maximum sequence length is unknown and will truncate some sequences during the testing phase.

Another problem that I encountered is that the range is mask_valuenot available, is it possible to use np.nanor np.infas a mask value?

+4
source share

Source: https://habr.com/ru/post/1674944/


All Articles