我有一个 BiLSTM,我通过序列抛出它,前向和后向 LSTM 使用 previos 序列输出,就像初始隐藏状态一样。它对前向 LSTM 有利,但对后向 LSTM 不利,因为当它以这种方式工作时,前向 LSTM 状态正在跳过序列。那么对于每个时间步,我可以将 BiLSTM 的后向部分重置为零初始状态吗?
这里有一个小例子:
# forward LSTM
forwarf_LSTM = LSTM(units=LSTM_units,
return_sequences=True,
recurrent_dropout=LSTM_dropout,
stateful=True,
activation='tanh',
recurrent_activation='tanh',
batch_input_shape=(BATCH_SIZE, MAX_LEN, N_FEATURES))(input_layer)
# backward LSTM
backward_LSTM = LSTM(units=LSTM_units,
return_sequences=True,
recurrent_dropout=LSTM_dropout,
go_backwards=True,
stateful=True,
activation='tanh',
recurrent_activation='tanh',
batch_input_shape=(BATCH_SIZE, MAX_LEN, N_FEATURES))(input_layer)