
Masked object classification loss (Kamath Eq 9.12)
Source:R/kamath_llm2_native.R
morie_kamath_ch9_moc_loss.RdSummed cross-entropy over the masked image regions. 1-D labels are
0-BASED class indices; 2-D labels must be one-hot rows. as_printed
carries the book's sign, which is the negative of a loss.
Examples
morie_kamath_ch9_moc_loss(NULL, NULL, NULL, matrix(c(0.7, 0.2,
0.3, 0.8), 2), labels = c(0, 1))
#> $estimate
#> [1] 0.5798185
#>
#> $as_printed
#> [1] -0.5798185
#>
#> $per_region
#> [1] 0.3566749 0.2231436
#>
#> $true_class_probability
#> [1] 0.7 0.8
#>
#> $n_masked_regions
#> [1] 2
#>
#> $n
#> [1] 2
#>
#> $method
#> [1] "masked object classification loss (Kamath Eq 9.12)"
#>