
Bidirectional RNN forward pass (Geron Ch 14, morie.fn hmbrnn)
Source:R/geron_ml_native.R
morie_geron_bidirectional_rnn.RdBackward states are re-aligned to the original time index before the
concatenation, so output[t, ] mixes prefix and suffix at t.
Usage
morie_geron_bidirectional_rnn(
X,
Wx_f,
Wh_f,
Wx_b,
Wh_b,
b_f = NULL,
b_b = NULL,
h0_f = NULL,
h0_b = NULL,
activation = "tanh"
)Examples
morie_geron_bidirectional_rnn(matrix(c(1, 1, 0.5), ncol = 1),
matrix(1), matrix(0.5), matrix(1), matrix(-0.5))
#> $output
#> [,1] [,2]
#> [1,] 0.7615942 0.5894633
#> [2,] 0.8811296 0.6463135
#> [3,] 0.7354816 0.4621172
#>
#> $h_fwd
#> [,1]
#> [1,] 0.7615942
#> [2,] 0.8811296
#> [3,] 0.7354816
#>
#> $h_bwd
#> [,1]
#> [1,] 0.5894633
#> [2,] 0.6463135
#> [3,] 0.4621172
#>
#> $final
#> [1] 0.7354816 0.5894633
#>
#> $hidden_size
#> [1] 1
#>
#> $estimate
#> [1] 0.6793499
#>
#> $n
#> [1] 3
#>
#> $method
#> [1] "Bidirectional RNN with concatenated forward/backward states"
#>