
Encoder-decoder seq2seq decoding loop (Geron Ch 16, morie.fn gredsq)
Source:R/geron_train_native.R
morie_geron_encoder_decoder_seq2seq.Rdc = 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
)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
#>