
GAN minimax objective (Geron Ch 17, morie.fn grgan)
Source:R/geron_train_native.R
morie_geron_gan_minimax.RdV = mean log D(x) + mean log(1 - D(G(z))) after clipping to [eps, 1-eps]; the accuracy uses the UNCLIPPED probabilities.
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
#>
morie_geron_gan_minimax(real = x, fake = x, D_real = x, D_fake = x)
#> $value
#> [1] -21.06985
#>
#> $d_loss
#> [1] 21.06985
#>
#> $g_loss_nonsaturating
#> [1] 7.081042
#>
#> $g_loss_saturating
#> [1] -13.98881
#>
#> $d_accuracy
#> [1] 0.5
#>
#> $at_equilibrium
#> [1] FALSE
#>
#> $n_real
#> [1] 2
#>
#> $n_fake
#> [1] 2
#>
#> $estimate
#> [1] -21.06985
#>
#> $n
#> [1] 8
#>