Skip to contents

c = encoder(x) once, then greedy y_t = decoder(y_prev, c, t) with the shape and finiteness contracts enforced at every step.

Usage

morie_geron_encoder_decoder_seq2seq(
  encoder,
  decoder,
  x,
  max_out_len,
  start_token = NULL,
  eos_token = NULL
)

Arguments

encoder, decoder

Functions; decoder(y_prev, c, t) with t 1-based as in the Python loop.

x

Encoder input.

max_out_len

Maximum number of decoding steps.

start_token

Optional initial y_prev; default zeros like c.

eos_token

Optional scalar that stops decoding.

Value

List with outputs, context, context_dim, n_steps, stopped_early.

Examples

x <- matrix(c(1, 0, 0.5, 1), 2, byrow = TRUE)
morie_geron_encoder_decoder_seq2seq(function(x) c(sum(x), 1),
    function(yp, cc, t) as.numeric(yp) * 0.5 + cc[1]/t, c(1,
        2, 3), 4)
#> $outputs
#> $outputs[[1]]
#> [1] 6 6
#> 
#> $outputs[[2]]
#> [1] 6 6
#> 
#> $outputs[[3]]
#> [1] 5 5
#> 
#> $outputs[[4]]
#> [1] 4 4
#> 
#> 
#> $context
#> [1] 6 1
#> 
#> $context_dim
#> [1] 2
#> 
#> $n_steps
#> [1] 4
#> 
#> $stopped_early
#> [1] FALSE
#> 
#> $estimate
#> $estimate[[1]]
#> [1] 6 6
#> 
#> $estimate[[2]]
#> [1] 6 6
#> 
#> $estimate[[3]]
#> [1] 5 5
#> 
#> $estimate[[4]]
#> [1] 4 4
#> 
#> 
#> $n
#> [1] 4
#>