
Combine the two directions of a bidirectional layer (Geron Ch 14, grbrnn)
Source:R/geron_ml_native.R
morie_geron_bidirectional_combine.RdPairs already-computed forward and backward states. Set
backward_in_reverse_order = TRUE when the backward stack is still in
emission order (last time step first) – the classic silent bug.
Usage
morie_geron_bidirectional_combine(
h_forward,
h_backward,
backward_in_reverse_order = FALSE,
combine = "concat"
)Examples
V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_geron_bidirectional_combine(V, V)
#> $h
#> [,1] [,2]
#> [1,] 1 1
#> [2,] 2 2
#> [3,] 3 3
#> [4,] 4 4
#> [5,] 5 5
#> [6,] 6 6
#> [7,] 7 7
#> [8,] 8 8
#>
#> $output_dim
#> [1] 2
#>
#> $n_steps
#> [1] 8
#>
#> $forward_dim
#> [1] 1
#>
#> $backward_dim
#> [1] 1
#>
#> $combine
#> [1] "concat"
#>
#> $estimate
#> [1] 4.5
#>
#> $n
#> [1] 8
#>
#> $method
#> [1] "Bidirectional RNN state concatenation"
#>