How to apply to the RNN input features represented by a list of vectors (equivalent to a sentence), and not with a single vector (equivalent to a word)?
Now, for each word in the sentence, I calculate a vector representation (word2vec), multiply by TF-IDF and average, it turns out one vector of fixed dimension. And I want to give to the input not an average, but a sequence.
# Сейчас модель такая - 2 фичи - 2 вектора размерности 300 на входе r_model = Sequential() r_model.add(LSTM(200, input_shape=(2, 300), return_sequences=True)) r_model.add(LSTM(300, return_sequences=True)) ... I want to supplement the lists of word vectors with zero vectors up to the maximum length - 105. And then submit this sequence to the input:
# Хочется подавать на вход последовательность # max_len - максимальная длина списка векторов max_len = 105 r_model = Sequential() r_model.add(LSTM(200, input_shape(2, max_len, 300), return_sequences=True)) r_model.add(LSTM(300, return_sequences=True)) ... But keras says that a shape of 3 is required, not 4, as in the second case:
Input 0 is incompatible with layer lstm_5: expected ndim=3, found ndim=4