Read the equation
This relation defines KL in the source section “func (g *VariationalGenerator) klDivergence(mu, logVar []float64) float64 · KL”. Uses logarithmic scaling; its base and the positivity of its argument matter. Its interpretation depends on the source’s stated variables and conditions; this record does not assign an unprovided physical or cognitive meaning to them.
Terms & definitions
The recovered passage does not supply a separate symbol table. Read the source context for the notation used in this version; familiar letters may carry different meanings in other builds.
How it works
Read KL as the quantity being defined or updated by this relation.
Uses logarithmic scaling; its base and the positivity of its argument matter.
Use this version’s variable definitions and update order. The same symbol may be assigned a different meaning in another build.
Assumptions & limits
This source expression was recovered from the pinned code revision. Its presence does not establish that the associated program was built, run, or scientifically validated.
Original context
Read the surrounding source passage
return g.ActivationLayer(hidden, "sigmoid")
}
// klDivergence computes KL divergence from N(0,1)
func (g *VariationalGenerator) klDivergence(mu, logVar []float64) float64 {
kl := 0.0
for i := range mu {
// KL = -0.5 * sum(1 + log(σ²) - μ² - σ²)
kl += -0.5 * (1.0 + logVar[i] - mu[i]*mu[i] - math.Exp(logVar[i]))
}
return kl / float64(len(mu))
}
// Forward performs forward pass
func (g *VariationalGenerator) Forward(input []float64) (*generators.GeneratorOutput, error) {
state := g.GetState()
// EncodeExact original notation
KL = -0.5 * sum(1 + log(σ²) - μ² - σ²)