Read the equation
The expectation of log q(z)−log p(x,z) equals KL(q(z)||p(z|x))−log p(x). The p in the abbreviated divergence must therefore mean the posterior, not simply the prior. The body’s FreeEnergy class instead computes a diagonal-Gaussian prior KL minus a supplied log-likelihood scalar; that is the alternate ELBO form when the scalar represents the expected log likelihood. Its mean update uses only the prior-KL gradient and does not use observation or likelihood gradients.
Terms & definitions
| Term | Meaning in this source |
|---|---|
| q | Variational distribution |
| p_x_z | Joint generative density |
| p_z_given_x | Posterior |
| F | Variational free energy |
How it works
Use Bayes’ identity log p(x,z)=log p(z|x)+log p(x).
Substitute this into E_q[log q(z)−log p(x,z)].
Recognize the expected log-density ratio as KL(q(z)||p(z|x)); the remaining term is −log p(x).
When expressing the same objective using a prior, write KL(q(z)||p(z))−E_q[log p(x|z)] instead.
Assumptions & limits
Source recovery establishes that the expression appears in this record. Its mathematical validity, implementation behavior, and interpretation must be assessed separately. See the linked source and research notes for the checks available for this version.
Original context
Read the surrounding source passage
// // 2. INFORMATION GEOMETRY // ds² = gᵢⱼ(θ)dθⁱdθʲ (Fisher information metric) // gᵢⱼ = E[∂log p/∂θⁱ · ∂log p/∂θʲ] // // 3. FREE ENERGY PRINCIPLE // F = E_q[log q(z) - log p(x,z)] // = D_KL(q||p) - log p(x) // // 4. ATTENTION MECHANISM // Attention(Q,K,V) = softmax(QK^T/√d_k)V // // 5. PREDICTIVE CODING // ε = x - μ (prediction error) // μ_new = μ + α·ε (update prediction) // // ═══════════════════════════════════════════════════════════════════════════════
Exact original notation
F = E_q[log q(z) - log p(x,z)] = D_KL(q||p) - log p(x)