Skip to contents

p = softmax(z/T); T -> 0 greedy, T -> inf uniform, ranking never changes. argmax is 0-based.

Usage

morie_geron_temperature_sampling(logits, T = 1)

Arguments

logits

Score vector.

T

Strictly positive temperature.

Value

List with probabilities, entropy, perplexity, argmax.

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