Skip to contents

Pairs 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"
)

Arguments

h_forward, h_backward

State matrices (T, H).

backward_in_reverse_order

Flip h_backward before pairing.

combine

One of "concat", "sum", "mean".

Value

List with h, output_dim, n_steps, forward_dim, backward_dim.

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"
#>