A bidirectional RNN processes each sequence twice: one recurrent layer reads chronologically, another reads antichronologically, and their representations are merged. This exposes patterns that a unidirectional layer may overlook. It is useful when sequence order matters and is frequently applied in natural language processing. section 13.3.6
Bidirectional LSTM for temperature forecasting
inputs <- keras_input(shape = c(sequence_length, ncol_input_data)) outputs <- inputs |> layer_bidirectional(layer_lstm(units = 16)) |> layer_dense(1) model <- keras_model(inputs, outputs) model |> compile(optimizer = "adam", loss = "mse", metrics = "mae") history <- model |> fit(train_dataset, epochs = 10, validation_data = val_dataset) section 13.3.3
Keep these practical points in mind:
- Use two familiar recurrent layers, such as GRU or LSTM, and merge their directional representations. section 13.3.6
- Do not assume reversing inputs is equivalent: a reversed-order LSTM strongly underperformed the commonsense baseline in temperature forecasting. section 13.3.6



