fix: change integrand check order in KL divergence code
This commit is contained in:
parent
fd17da83b8
commit
87d6f8d4f6
|
@ -4,10 +4,10 @@ module KLDivergence = {
|
||||||
float,
|
float,
|
||||||
Operation.Error.t,
|
Operation.Error.t,
|
||||||
> =>
|
> =>
|
||||||
if predictionElement == 0.0 {
|
if answerElement == 0.0 {
|
||||||
Error(Operation.NegativeInfinityError)
|
|
||||||
} else if answerElement == 0.0 {
|
|
||||||
Ok(0.0)
|
Ok(0.0)
|
||||||
|
} else if predictionElement == 0.0 {
|
||||||
|
Error(Operation.NegativeInfinityError)
|
||||||
} else {
|
} else {
|
||||||
let quot = predictionElement /. answerElement
|
let quot = predictionElement /. answerElement
|
||||||
quot < 0.0 ? Error(Operation.ComplexNumberError) : Ok(answerElement *. logFn(quot))
|
quot < 0.0 ? Error(Operation.ComplexNumberError) : Ok(answerElement *. logFn(quot))
|
||||||
|
|
Loading…
Reference in New Issue
Block a user