Intuitively Understanding the KL Divergence

2021 ж. 12 Сәу.
75 149 Рет қаралды

This video discusses the Kullback Leibler divergence and explains how it's a natural measure of distance between distributions. The video goes through a simple proof, which shows how with some basic maths, we can get under the KL divergence and intuitively understand what it's about.

Пікірлер
  • I just want to say. This is--by far--the best explanation of KL divergence I've found on the internet. Thanks so much!

    @Vroomerify@Vroomerify Жыл бұрын
  • This was actually one of the most helpful videos. Thank you

    @niofer7247@niofer7247 Жыл бұрын
  • You are unbelievably good at teaching man. You explained it better than they did in my course.

    @nericarcasci9919@nericarcasci9919 Жыл бұрын
  • holy smoke, you are legit GOAT. so concise yet clear and intuitive explanation.

    @jimmygan801@jimmygan8012 жыл бұрын
  • Great video! Loved the intuition behind the KL distribution. For some thinking about applications, this is used in the loss function of Variational Auto Encoders, a class of deep networks, and is used to find low dimensionality features of high dimensionality input data as an encoder. (e.g. use this to deconstruct images into "features")

    @marcegger7411@marcegger74112 жыл бұрын
  • Thanks for the brilliant, intuitive and crystal-clear explanation!

    @drondasgupta9378@drondasgupta9378 Жыл бұрын
  • Thanks, that made the idea make a lot more sense to me. Showing how it arises so nicely from a large sample size, made it feel much more natural.

    @drdca8263@drdca82632 жыл бұрын
  • Thanks for the simple, yet helpful, explanation!

    @farshadsaberi2740@farshadsaberi27402 жыл бұрын
  • I didn't expect that good explanation from a randomly suggested youtube video

    @baskaisimkalmamisti@baskaisimkalmamisti2 жыл бұрын
  • KL divergence confused me for so long, and I understood it just by watching your video for one time, thank you very much!

    @liliz1902@liliz1902 Жыл бұрын
  • This type of explanation is perfect! First boiling the problem down to the most intuitive understanding and from there deduce the general formula. Thanks so much!

    @karstenhannes9628@karstenhannes962810 ай бұрын
  • I'm just rewatching this video to freshen up my deep learning fundamentals. Super clear video, thank you so much!

    @wynandwinterbach455@wynandwinterbach4554 ай бұрын
  • One of the most useful explanations ever. Thanks!!

    @germangarcia5599@germangarcia5599 Жыл бұрын
  • Great explanation! One technical remark I have is that (from my understanding) KL divergence is not technically a measure of distance, since it's not symmetric ( Dlk(P||Q) != Dlk(Q||P) ).

    @haresage6110@haresage6110 Жыл бұрын
    • Yes, that's why it's called divergence instead of distance.

      @charchitsharma8902@charchitsharma89023 ай бұрын
  • Thanks Adian! The connection back to cross entropy loss is cool. Slowly coming together for me.

    @moopoo123@moopoo123 Жыл бұрын
  • Thank you so much for this content. By far the explanation of KL Divergence seen so far

    @alkanair7325@alkanair7325 Жыл бұрын
  • Great video. Thanks for sharing. Really intuitive.

    @karthikeyans3@karthikeyans36 ай бұрын
  • This is awesome, thanks for breaking it down Adian

    @alecpanayotov@alecpanayotov Жыл бұрын
  • Thank you so much for this video and clear explanation!

    @brianlee4966@brianlee49663 ай бұрын
  • Thanks so much for this, needed to understand what KL Divergence is for a paper I'm reading and you just saved me so much time!

    @matakos22@matakos222 жыл бұрын
  • Great explanation. Thank you so much!

    @shahriarrahman8425@shahriarrahman8425Ай бұрын
  • Best explanation on the interwebs!

    @ian-haggerty@ian-haggertyАй бұрын
  • Very well-explained. Thank you!

    @soroushmehraban@soroushmehraban Жыл бұрын
  • Very well explained! Thank you!

    @ramendrachaudhary9784@ramendrachaudhary97842 жыл бұрын
  • Amazing explanation, thanks!

    @petercourt@petercourt Жыл бұрын
  • Perfectly explained in 5 minutes. Wow.

    @adityakulkarni5577@adityakulkarni5577Ай бұрын
  • Concise and clear, thank you!

    @filipedstrom4462@filipedstrom44622 жыл бұрын
  • thx for sharing very helpful and intuitive.

    @gaoyang6608@gaoyang66082 жыл бұрын
  • Bro, this intuition was not normal, u r just genius!!

    @sharingpurpose237@sharingpurpose237 Жыл бұрын
  • Beautiful explanation!

    @tudor6210@tudor6210 Жыл бұрын
  • Keep the vids coming this is so so useful

    @researchmedicine6950@researchmedicine69502 жыл бұрын
  • Very great explanation!

    @alifarrokh9863@alifarrokh9863 Жыл бұрын
  • Great content! Thank you.

    @adamtaylor2142@adamtaylor21426 ай бұрын
  • A question here why will the number of heads and number of tails be the same for both the distributions at 3:04. If the probabilities for both the coins are different then the number of occurrences of heads and tails can also be different

    @AashraiRavooru@AashraiRavooru Жыл бұрын
  • Very good video. Thanks so much!

    @annaly2318@annaly23182 жыл бұрын
  • this was great and super useful in my internship (which really just started), Thanks! :)

    @zukofire6424@zukofire6424 Жыл бұрын
  • This was awesome. Thank you.

    @blakeedwards3582@blakeedwards35822 жыл бұрын
  • excellent explanation

    @jessechen6541@jessechen65412 жыл бұрын
  • thank you so much, very nicely explained

    @yatinarora9650@yatinarora9650 Жыл бұрын
  • This is so intuitive!!!!!!!!!❤

    @clairewang8370@clairewang8370 Жыл бұрын
  • This was very good have liked and subscribed

    @hackercop@hackercop2 жыл бұрын
  • Great video . Thanks.

    @thapargerrard123@thapargerrard123 Жыл бұрын
  • Wow this is an amazing explanation. So is KL divergence equivalent to Bayes factor with equal priors?

    @user-sx4wm5ls5q@user-sx4wm5ls5q2 жыл бұрын
  • Thanks for the explanation!! One thing is, formulas were confusing with how you denoted *q1* & *q2* for probabilities for coin 2, instead of *p2* & *q2=1-p2*

    @kukuster@kukuster6 ай бұрын
  • thanks a lot ! 5min for explaining what I could'nt understand in hours

    @reformed8246@reformed8246 Жыл бұрын
  • super helpful! Thank you

    @longh@longh Жыл бұрын
  • Thanks for the explanation. With the RLHF stuff happening in ChatGPT, does anyone know why they choose to use KL divergence instead of Cross-entropy loss when calculating the RL policy penalty?

    @xxluapxx@xxluapxx Жыл бұрын
  • This video is amazing

    @Gathanokos@Gathanokos2 жыл бұрын
  • Finally a simple explanation

    @Luca-yy4zh@Luca-yy4zh2 жыл бұрын
  • Excellent video. Can someone help me understand why is it called Divergence in the first place? Why are we taking 1/N power to normalise it to sample space, I did not understand the logic behind this.

    @SunilKumarSamji@SunilKumarSamji2 ай бұрын
  • Nice video! Can you say something about alternatives? E.g. why wouldn't mean squared error (of two probability distributions) work as well?

    @JingyueWu@JingyueWu8 ай бұрын
  • Just perfect!

    @ananya_sutradhar@ananya_sutradhar7 ай бұрын
  • Excellent!!!

    @juliocardenas4485@juliocardenas44852 жыл бұрын
  • This is gold!

    @unbridled_exciton@unbridled_exciton Жыл бұрын
  • @3:26 I don't understand how are we normalizing by raising it to the power of 1/N. Could you please explain that?

    @balasubramanyamevani7752@balasubramanyamevani77522 жыл бұрын
    • Same question here. This is a fantastic explanation but it defeats me when you mention “we normalize by raising to power of 1/N”. Why do we do this? What does that do or mean to the data? Thanks for making this video! Awesome!

      @Chris-zg1me@Chris-zg1me Жыл бұрын
    • I think the 1/N gives us the 'average' probability of a single toss; e.g. if we had a fair coin and had 3 tosses, the probability of our sequence would be 1/2 * 1/2 * 1/2 = 1/8. If we had ten tosses, the probability of the sequence would be 1/(2^10). These numbers are currently incomparable. If we now look at the probability of the sequence to the power of 1/N, where N is the number of tosses, then suddenly they are the same ... which is what we would want .... it basically normalizes the probability sequence!

      @vyasraina3930@vyasraina3930 Жыл бұрын
    • @@vyasraina3930 thanks for the explaination! in general why is power 1/N more important than let's say multiplying by 1/N?

      @aniruddhajoshi7496@aniruddhajoshi74965 ай бұрын
    • @@vyasraina3930 so basically the 1/N gets rid of the number of tosses/sample size and in your case of a fair coin makes it so the probability would be 1/2 regardless of N by getting rid of the N (exponent in your probability sequence)

      @franklyvulgar1@franklyvulgar113 күн бұрын
  • Thank you!

    @akshaydongare2136@akshaydongare2136 Жыл бұрын
  • Thanks very much.

    @amrahmed2009@amrahmed20092 жыл бұрын
  • Thank you a lot

    @mormonteg4073@mormonteg40736 ай бұрын
  • Great video! Can you make a video about soft actor critic?

    @cuongnguyenuc1776@cuongnguyenuc17763 ай бұрын
  • Thank you so much

    @vi5hnupradeep@vi5hnupradeep2 жыл бұрын
  • beautiful!

    @yihongli350@yihongli350 Жыл бұрын
  • ...tremendous!

    @BillHaug@BillHaug7 ай бұрын
  • Thank you! May I ask how you made the video? I want the numbers to move like they do in your show. It looks great and maintains comprehensibility by bringing it to life! We have to make a video about AIC for our neuroinformatics class, so your video would be a nice introduction to the topic anyway... You do it a little better than our prof^^

    @DC-gq6ww@DC-gq6ww2 жыл бұрын
    • This might break the magic a bit but I just use plain old fashioned Microsoft power point! To move the equations I use the inbuilt animations functionality, though it can get a bit tedious to make everything move exactly how you’d like to. But best of luck on making your video.

      @adianliusie590@adianliusie5902 жыл бұрын
    • @@adianliusie590 thx for your answer! Good to know. It doesn't break the magic. I just use another program and I am a noob at some points

      @DC-gq6ww@DC-gq6ww2 жыл бұрын
  • Nice video :)

    @dogukan463@dogukan4632 жыл бұрын
  • Greaaaat job

    @hamzeasadi671@hamzeasadi671 Жыл бұрын
  • Awesome

    @salehmontazeran1130@salehmontazeran1130 Жыл бұрын
  • Awesome video, but at 3:27, on what basis did we take the log?

    @Darkev77@Darkev772 жыл бұрын
    • That's a good question which I'm not sure I could answer too well. One could claim that the log function makes numbers more readable, and often when we deal with large/small numbers we log expressions first since the log operation is reversible and squeezes the range into a smaller one (e.g. e^10, about 22000, becomes 10), like is done with things like log probabilities. It could also just be mathematical convenience to drop the powers so that the overall expression looks much simpler. However I think you'd find a more satisfying answer by looking in the direction of entropy, as entropy is defined as the expected log probabilities of a distribution. Since the KL is interlinked tightly with entropy, something may drop out there which will show that logging the ratio makes the expression more natural and intuitive. I'd have to think bout it more, and maybe I'll make a video on entropy in the near future, but if I figure anything out I'll get back to you then.

      @adianliusie590@adianliusie5902 жыл бұрын
    • @@adianliusie590 wow that’s such a great answer. I truly appreciate that! And yeah, what you said makes sense, and with regards to entropy you’re very right; since entropy is the expected/avg information of a distribution of random events and KL div measures the *relative* difference in expected information between two distributions.

      @Darkev77@Darkev772 жыл бұрын
    • Hi Darkev and Adian, there is another video on youtube (study squad academy) which explains the KL divergence from the perspective of Jensen's inequality. The main argument for taking the log is that it is a concave function, which does somewhat touch Adian's comment.

      @skeletonrowdie1768@skeletonrowdie17682 жыл бұрын
  • So fire

    @joshholder359@joshholder359 Жыл бұрын
  • So a Kale Divergence of zero means identical distributions? What do the || lines mean?

    @ian-haggerty@ian-haggertyАй бұрын
  • Dude just plops in some God-tier eye openers in the credits and leaves. Never realized this relationship between KL and cross-entropy loss.

    @ferkstkojtt@ferkstkojtt2 жыл бұрын
  • Only that is not a distance ('cause is not symmetric), but a pseudo distance. Great video!

    @akidnag@akidnag6 ай бұрын
  • The vedio is good, but what confuses me is the correctness of the division. Sometimes,we have different probability(like NH = NT = 1,and p1=q2,p2=q1),but the division result is 1,which mean they are similar ,or same. It is wrong actually. So, may this explanation is just coinstance, or I have made some mistakes. Hopefully you can help me.(If my pool english make it confusing, I am sorry for that)

    @yingliu350@yingliu3502 жыл бұрын
  • Hi, I don't get why you assume that the nH and nT for the coin two would be the same as the coin 1?

    @yashrathi6862@yashrathi68622 жыл бұрын
    • Yeah i don't get it either, any explainations anyone?

      @Marcus-ok2jy@Marcus-ok2jy Жыл бұрын
    • @@Marcus-ok2jy nH and nT are just the number of heads and tails generated in the sequence by the 'true coin', not by coin 2.. i.e., if i have a true coin and I flip it a few times I may get H,H,T,H (nH=3, nT=1) and you will notice that nH/N=0.75 and nT/N =0.25 which is not equal to p1 and p2 respectively. However, if were to flip the coin many more times, infinitely more times, we would notice the number of heads is the same as the number of tails. Thus, he is saying in the limit of a sufficient amount of coin flips, we will notice nH/N = 0.5 and nT/N = 0.5.

      @Drewbie_T@Drewbie_T Жыл бұрын
    • @@Drewbie_T Hi Andrew, But in 3:21 , the formula P(observations|coin 2) looks at the nH and nT of Coin 2 does it not? This is so that the KL divergence could take into the account the disparity in probability distribution between the 2 coins.

      @Marcus-ok2jy@Marcus-ok2jy Жыл бұрын
    • @@Marcus-ok2jy No it does not, it is only looking at nH and nT of the true coin. Coin 2 is not being flipped at all. The only part where coin 2 comes in is after flipping the true coin (which has probability p1 heads and p2 tails), we obtain some chain of outcomes (i.e., H,H,T,H,T,T). Now that we have flipped the true coin and obtained an outcome, we look at the coin 2 probabilities and say, how likely is it that this sequence (H,H,T,H,T,T) could have come from coin 2? If coin 2 has .95 probability of landing on heads every time, it is unlikely that we would see an equal number of heads and tails in the distribution.

      @Drewbie_T@Drewbie_T Жыл бұрын
    • It's because we first flip a coin N times and record the number of heads (nH) and the number of tails (nT). It is assumed here that the coin used here repesents the real coin (which has p1 probability for head and p2 probability for tail). We are now interested in finding how close coin 2 can mimic the real coin's flips. And since the real coin produced nH heads and nT tails during our experiment, we use the same values. Hope this helped.

      @adytya@adytya Жыл бұрын
  • 😁😁😁gotcha. super ez explanation

    @treksis@treksis Жыл бұрын
  • nice

    @cliveemary4806@cliveemary4806 Жыл бұрын
  • @ian-haggerty@ian-haggertyАй бұрын
  • Why raise to 1/n power, why use log? Why don't we use just sum(P/Q)?

    @onamixt@onamixt8 ай бұрын
  • I love you Biradr

    @ViralPanchal97@ViralPanchal978 ай бұрын
  • KL loss is not exactly equivalent to cross entropy loss right

    @zyzhang1130@zyzhang1130 Жыл бұрын
  • I still dont know why the log appears there.

    @gzitterspiller@gzitterspiller Жыл бұрын
  • It has my initials

    @1.4142@1.4142 Жыл бұрын
  • wowowowo

    @user-ut4zh3pw7l@user-ut4zh3pw7lАй бұрын
  • So, Why is KL Divergence is not symmetric?

    @gottlobfreige1075@gottlobfreige10752 жыл бұрын
  • great explanation, would be perfect if you speaked slower

    @_jiwi2674@_jiwi26742 жыл бұрын
  • when you say "likelyhood of the observation of each coin", you really mean "probability" instead of "likelyhood", right?

    @Justin-zw1hx@Justin-zw1hx Жыл бұрын
  • It’s technically not “distance”

    @zjy2936@zjy29362 жыл бұрын
  • It is not a measure of distance between distributions!

    @yegounkim1840@yegounkim1840 Жыл бұрын
  • Thanks so much

    @Yassinius@Yassinius Жыл бұрын
KZhead