Я использую AttentionDecoder, предоставленный в AttentionDecoder , чтобы выполнить текстовую классификацию данных Sentiment140.Размер моих тренировочных данных (1280000, 50)
.Сначала я изменяю набор данных в (12800, 50, 100)
, следуя традиционной схеме ввода (batch_size, time_steps, input_dim)
.Модель, которую я построил с использованием Keras, приведена здесь:
def get_bi_lstm_with_attention_model(pad_length, dim):
input_shape = (pad_length, dim)
input = Input(shape=input_shape, dtype='float32')
enc = Bidirectional(LSTM(100, dropout=0.2, recurrent_dropout=0.2, return_sequences=True),
merge_mode='concat', name='bidirectional_1')(input)
y_hat = AttentionDecoder(units=32,output_dim=1, name='attention_decoder_1')(enc)
bilstm_attention_model = Model(inputs=input, outputs=y_hat)
bilstm_attention_model.compile(loss='binary_crossentropy', optimizer='adam', metrics=['accuracy'])
return bilstm_attention_model
После установки pad_length=50
и dim=100
я хочу использовать созданную модель для соответствия данным:
bilstm_model_with_attention.fit(sentiment_sequence_for_train_attention, labels_for_train, validation_split=0.25, epochs=3, batch_size=128)
Тогда я получил следующую ошибку:
ValueError: Error when checking target: expected attention_decoder_1 to have 3 dimensions, but got array with shape (1280000, 1)
Следовательно, я запутался!Я знаю, что это должно быть что-то не так с входными размерами.Кто-нибудь может предложить несколько советов?