deep learning - Give Variable Length input to LSTM - Data ...
datascience.stackexchange.com › questions › 40708Dec 04, 2018 · X_train = sequence.pad_sequences(X_train, maxlen=padding_size) X_test = sequence.pad_sequences(X_test, maxlen=padding_size) model = Sequential() model.add(Embedding(50, 10, input_length=X_train.shape[1], mask_zero=True)) if isBidirectional: model.add(Bidirectional(LSTM(lstm_layer_number))) else: model.add(LSTM(lstm_layer_number)) if isDropout: model.add(Dropout(0.5)) model.add(Dense(1, activation='sigmoid')) model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy ...