
Temperature-scaled softmax (Geron Ch 16, morie.fn grtmp)
Source:R/geron_train_native.R
morie_geron_temperature_sampling.Rdp = softmax(z/T); T -> 0 greedy, T -> inf uniform, ranking never
changes. argmax is 0-based.
Examples
V <- c(1, 2, 3, 4, 5, 6, 7, 8)
morie_geron_temperature_sampling(V)
#> $probabilities
#> [1] 0.0005766128 0.0015673960 0.0042606241 0.0115815771 0.0314819905
#> [6] 0.0855769227 0.2326221940 0.6323326828
#>
#> $entropy
#> [1] 1.037632
#>
#> $perplexity
#> [1] 2.822525
#>
#> $argmax
#> [1] 7
#>
#> $temperature
#> [1] 1
#>
#> $estimate
#> [1] 0.0005766128 0.0015673960 0.0042606241 0.0115815771 0.0314819905
#> [6] 0.0855769227 0.2326221940 0.6323326828
#>
#> $n
#> [1] 8
#>