fix: change integrand check order in KL divergence code

This commit is contained in:
NunoSempere 2022-05-06 09:49:42 -04:00
parent fd17da83b8
commit 87d6f8d4f6

View File

@ -4,10 +4,10 @@ module KLDivergence = {
float,
Operation.Error.t,
> =>
if predictionElement == 0.0 {
Error(Operation.NegativeInfinityError)
} else if answerElement == 0.0 {
if answerElement == 0.0 {
Ok(0.0)
} else if predictionElement == 0.0 {
Error(Operation.NegativeInfinityError)
} else {
let quot = predictionElement /. answerElement
quot < 0.0 ? Error(Operation.ComplexNumberError) : Ok(answerElement *. logFn(quot))