Lecture 9: Energy-Based Models 1 (KAIST CS479, Fall 2026)
Overview
Minhyuk Sung develops energy-based models (EBMs), where a neural network assigns each data point a scalar energy and defines its probability density through a normalized exponential of negative energy. He derives the maximum-likelihood gradient as a competition between lowering energy on training examples and raising it on samples from the current model, then introduces Markov chain Monte Carlo and Langevin dynamics for sampling without computing the partition function.
Key takeaways
- An EBM defines density as p(x) = exp(-E(x))/Z, making lower energy correspond to higher probability while leaving the neural network's raw energy output unconstrained.
- Maximum-likelihood training creates a two-sided gradient: lower energy on real training examples and higher energy on samples from the current model.
- The partition function is difficult to calculate, but it cancels in density ratios and does not affect the gradient of log density with respect to an input.
- Markov chain Monte Carlo samples from complex target distributions by repeatedly applying a transition kernel whose stationary distribution is the target.
- Langevin dynamics combines movement along the negative energy gradient with Gaussian noise; the noise enables distribution sampling rather than simple convergence to a local minimum.
- The score, defined as ∇ log p(x), equals -∇E(x) for an EBM and provides the key quantity for both sampling and score-based generative models.
Chapters
- A GAN trains a generator and a discriminator that classifies outputs as real or fake.
- With an optimal discriminator, outputs above 0.5 indicate regions underrepresented by the generator, while outputs below 0.5 indicate overrepresented regions.
- The original minimax generator loss can cause vanishing gradients, so a non-saturating generator loss is a common training alternative.
- GANs can work well but often require practical stabilization tricks.
- An EBM assigns each input a scalar energy that may be positive or negative, with no probability-style constraints on the raw output.
- The unnormalized density is proportional to exp(-E(x)), so lower energy corresponds to higher probability.
- A partition function normalizes the density by integrating exp(-E(x)) over the full input space, or summing it in a discrete space.
- Computing the partition function is generally intractable when E(x) is produced by a neural network.
- Ratios of two EBM densities can be computed from their energy values because the shared partition function cancels.
- Adding the same constant to every energy leaves the normalized probability distribution unchanged.
- Multiple constraints can be combined by adding energy functions, such as protein stability and target binding energies.
- An energy function can provide supervision even when large-scale training data is unavailable, as in molecule design.
- Minimizing average negative log likelihood gives a gradient with two expectations: one over training data and one over the current EBM distribution.
- The data expectation lowers energy on observed examples, increasing their probability.
- The model expectation raises energy on samples generated by the current model, discouraging excess probability in overrepresented regions.
- The partition-function gradient becomes an expectation under the model, avoiding direct evaluation of the partition function.
- The data-side expectation can be estimated with a mini-batch from the training set.
- Estimating the model-side expectation requires sampling from the current energy-defined distribution, making sampling central to EBM training.
- For an energy parameterized as a quadratic around a mean, the corresponding distribution is Gaussian.
- The mean parameter's likelihood gradient moves the learned Gaussian mean toward the data mean.
- Complex distributions generally cannot be sampled from directly, unlike a simple Gaussian with a known sampling procedure.
- EBMs aim to sample from a distribution specified by an energy function without training a separate generator network.
- Sampling is needed both to produce model outputs and to estimate the model expectation during maximum-likelihood training.
- The lecture introduces Markov chain Monte Carlo as a way to build samples through repeated transitions.
- A Markov chain generates a sequence of states where each next state depends only on the current state.
- A transition kernel specifies the conditional distribution used to move from the current state to the next.
- The target distribution is stationary if a state sampled from it remains distributed according to that same target after a transition.
- With suitable convergence conditions, repeated transitions from an initial distribution approach the target distribution.
- Langevin dynamics defines a transition using the energy gradient, a step size, and Gaussian noise.
- The negative energy gradient moves samples toward lower-energy regions, while Gaussian noise keeps the process stochastic.
- In the small-step-size limit with enough iterations, the chain targets the distribution defined by the energy function.
- The method connects statistical physics and molecular dynamics with generative-model sampling.
- A chain can begin from an arbitrary point, including a sample from a simple Gaussian distribution.
- Early states may not resemble samples from the target distribution, so the initial burn-in steps are discarded.
- Smaller step sizes and more chain iterations improve the approximation to the target distribution.
- For a simple quadratic energy, the stationary variance approaches the target variance as the step size approaches zero.
- Langevin sampling uses the energy gradient and Gaussian noise without evaluating the partition function.
- The sampling update depends on the gradient of the energy rather than its absolute value.
- The partition function is unnecessary for the update because it does not vary with the input point.
- This makes gradient information sufficient for sampling from an EBM-defined target.
- For an EBM, the negative energy gradient equals the gradient of the log density: ∇ log p(x) = -∇E(x).
- This gradient of log probability is called the score and can be modeled directly instead of predicting energy values.
- Score-based models use the score for sampling and connect the EBM discussion to later diffusion-model material.
- The partition-function term disappears from the score because it is constant with respect to the data point.
- Removing Gaussian noise from Langevin dynamics leaves a gradient-descent process that seeks low-energy local minima.
- Gradient descent does not reproduce the target distribution and can send different starting points toward the same local minimum.
- Noise supports diverse samples from the target distribution rather than only low-energy optima.
- The lecture closes by linking energy models, score functions, and sampling methods to upcoming score-matching and diffusion topics.
Transcript excerpt
0:02 Okay. So on last week uh we discussed the another kind of model which was the generative adversarial neuron net. Uh we chose the case that now we are training not a single neuronet but actually the two neuron nets and also making them like compete each other in terms of that we are having the uh the generator as usual and then we are also having the discriminator which is basically you know checking whether it's the output is kind of like real or the fake. uh so by jointly training this kind of the binary declassifier which is giving some kind of some learning signal uh to the other kind of the generator right so this was kind of the case that we are basically training our kind of model without explicitly basically evaluating the probability density for any kind of the data points. So that is kind of the the
0:50 case of the uh the generator. So we also discussed the kind of the the minmax to objective function to train those kind of the two neural networks and we discussed kind of the meaning of those kind of the objective function right. So when you basically see the minity function when you fix the the generator and basically assume some kind of equality prior for the real and the fake labels we could see that in the optimal case our the discriminator should return this specificity ratio right this kind of quantity which is having this kind of meaning right so when we have the optimal discriminator if the output is greater than 0.5 that's the case that our generator is the 0.5 at the certainly data point X here. Uh this is
1:38 kind of the region which is basically the hourly generator is kind like under
This is the start of the transcript. Save this video free for the whole transcript, searchable and time-coded.
In this course
Related notes
Summary, takeaways, and chapters were generated by AI from the video's transcript and may contain errors. The video belongs to its creator, Minhyuk Sung.