VQ-VAEs: Neural Discrete Representation Learning | Paper + PyTorch Code Explained

Поділитися
Вставка
  • Опубліковано 5 січ 2025

КОМЕНТАРІ •

  • @pawnagon4874
    @pawnagon4874 3 роки тому +18

    I wish I had one of these videos for every paper I read, awesome work

  • @dxd-q2e
    @dxd-q2e 3 роки тому +30

    Great explanation! Especially useful explanation of the code! Please keeping doing the code part! You are a life saver!

    • @TheAIEpiphany
      @TheAIEpiphany  3 роки тому

      Super valuable thanks! I'll consider maybe doing a walk-through of some code feel free to suggest something!

    • @iceinmylean3947
      @iceinmylean3947 2 роки тому

      @@TheAIEpiphany Id be really interested in anything related to the autoregressive model part also mentioned in this video, maybe something like training a transformer?

  • @汪宣甫-i1o
    @汪宣甫-i1o 2 роки тому +7

    I truly appreciate your explanations, especially PyTorch implementation part, which reduce the gap between concepts and real world implementations. Finding this channel is like finding treasures to me, I've recommended this channel to all my friends. Look forward to your weekly update, thanks :)

    • @TheAIEpiphany
      @TheAIEpiphany  2 роки тому +2

      Thanks man! 🙏 Yup I am getting back on track with UA-cam I had a weird period over the last month. 😄

  • @DCentFN
    @DCentFN 7 місяців тому +1

    Combining the code with the paper explanation helps the understanding immensely. Allows for concept as well as application. Thank you

  • @AmirHosseinAlamdar
    @AmirHosseinAlamdar 4 місяці тому +1

    Great! Also the code section was a very good idea. Saved a lot of time thanks.

  • @ShravanKumar147
    @ShravanKumar147 Рік тому +2

    Thank you for such a great explanation, adding code into this format is really helpful to digest the concepts more intuitively. Please keep them coming the same way.

  • @asddsfdsaasdf
    @asddsfdsaasdf Місяць тому +1

    great content, it really helps to understand theese papers. The code was also very helpfull . Thanks!

  • @elbayo421
    @elbayo421 11 місяців тому

    Amazing explanation! Thank you very much. I was a bit troubled about understanding how this model can be used to generate new images but after reading around I think I get it now

  • @hoanglinh96nl
    @hoanglinh96nl Рік тому

    00:01 VQ-VAE is a crucial model for AI research and used in various novel works.
    02:02 Variational autoencoders use a stochastic bottleneck layer.
    05:58 VQ-VAEs impose structure into the latent space for continuous and meaningful interpolation.
    07:50 Discrete representations are a natural fit for many modalities and enable complex reasoning and predictive learning.
    11:40 Using l2 norm to find closest vector and approximate posterior
    13:33 The likelihood assumption and the loss terms in VQ-VAEs
    17:18 Conversion of bchw tensor to standard representation
    18:59 VQ-VAEs use flat input and an embedding table to find distance to codebook vectors.
    22:27 Explanation of implementing straight through gradient
    24:09 The approximate posterior z given x is a deterministic function.
    27:37 The model is an autoregressive token predictor for generating novel images.
    29:11 VQ-VAEs compress data to a discrete space with code size k=512.
    32:24 VQ-VAE v2 has hierarchical structure for better reconstructions
    34:04 VQ-VAEs capture high-resolution images with some distortion
    Crafted by Merlin AI.

  • @Prashantserai
    @Prashantserai Рік тому

    Fantastic in every way, including the code explanation as well!

  • @vladimirtchuiev2218
    @vladimirtchuiev2218 Рік тому

    Finally a good explanation on how the autoregressive prior part works :X

  • @artikeshari5441
    @artikeshari5441 2 роки тому +3

    Thanks for explaining it very clearly. Code explanation makes the concept more robust.

  • @christiannowak7094
    @christiannowak7094 3 роки тому +1

    Brilliant, never got so close to understand what's going on. Really well done

  • @IgorAherne
    @IgorAherne Рік тому

    @TheAIEpiphany Man, that's such an epic explanation. Thank you so much for your help!
    One thing that I am struggling with, is 28:00 - by tweaking the prior, does that mean that we can trick the model about what "was" in the image? (what is is expected).
    The concept of predicting the next token is easy for me, - but what are we predicting? a next discrete-embedding vector from the table? But these vectors weren't guaranteed to be in any order...
    Or are we predicting the next word? In that case, how do we associate word token to the discrete-embedding vector?
    During teaching this autoregressive model, how do we know which one is the target/correct vector, that we want to be predicted?

    • @IgorAherne
      @IgorAherne Рік тому

      If anyone else has this question, the autoregressive model is an addition which doesn't "improve" the quality of the VQ-VAE.
      But, we can swap it instead of the encoder+codebook, and use it to produce new images. So basically, "autoregressiveModel+decoder".
      You have to remember that once VQ-VAE is learned, the codebook vectors will be frozen forever. They will not be shuffled etc.
      So, when deployed into production, the Autoregressive model doesn't care what encoder does.
      Instead, the autoregressive model has learnt to look at the few code-book indices (we pick them arbitrarily), and to generate remaining indices of codebook that it thinks will be relevant.
      For example, if we gave it and index describing sky, it might decide that a following index describing a cloud will be more likely, than, say, of a fish.
      Once the autoregressive model produced all the needed indices, we feed the chosen codebook-vectors into the decoder.
      This allows us to generate images.

  • @gougenot
    @gougenot Рік тому

    Very nice code part. Truly helped me to understand, what is happening

  • @stefanmai9879
    @stefanmai9879 Рік тому

    You're a great teacher! Glad you came back to this paper and love the format with the code walkthroughs. Very thorough!

  • @skymanaditya
    @skymanaditya 2 роки тому +1

    Loved the explanation, especially the part where you covered all the important aspects and showed them in the code. Subscribed and looking forward to more of this content!

  • @jasdeepsinghgrover2470
    @jasdeepsinghgrover2470 3 роки тому +2

    Thanks for the amazing video... You can make them longer and more detailed if needed... Really fun to watch

  • @yimingqu2403
    @yimingqu2403 3 роки тому +8

    Appreciate your work! Both paper and code parts are very helpful.
    Two suggestion to make the code more concise
    - pytorch has built in function to calculate pairwise distance `torch.cdist`.
    - directly using `index_select` to get the quantized matrix may be more convenient.

    • @TheAIEpiphany
      @TheAIEpiphany  3 роки тому

      Not my implementation - I agree why not reuse the existing library code when possible

    • @kyde8392
      @kyde8392 3 роки тому

      Your suggestions are really neat 👌

  • @ramensusho
    @ramensusho 4 місяці тому +1

    This was some nice explanation

  • @letianwang5141
    @letianwang5141 Рік тому +1

    best explanation ever, unbiased comment

  • @mehmetonur7925
    @mehmetonur7925 3 роки тому +7

    Code part is pretty good.It has made paper more clear.

  • @mathkernel5136
    @mathkernel5136 Рік тому

    How do we generate new images from the VQ-VAE model. Can you do a tutorial on the pix2pix model for generating new image samples? Thanks

  • @sarathmohan3143
    @sarathmohan3143 3 роки тому

    Thank a lot sir.
    Simple and concise explanation by covering the related basics also.

  • @TuanNguyen-su5ty
    @TuanNguyen-su5ty Рік тому

    This video is invaluable. Thank you

  • @modyngs1256
    @modyngs1256 Рік тому

    Hi,
    What's the application you are using to write on the PDF? i mean the way you write something in side with the original pdf in the black side of the pdf?

  • @mehdizahedi2810
    @mehdizahedi2810 5 місяців тому

    awesome presentation, thanks.

  • @alexijohansen
    @alexijohansen 3 роки тому

    Thank you. Love the code, love the in depth explanation! Explaining the math is also great for a beginner like me.

  • @evgenydyshlyuk5604
    @evgenydyshlyuk5604 3 роки тому +1

    Great choice of the article, thank you, was very interesting!

  • @zongtaowang7840
    @zongtaowang7840 2 роки тому

    thank you for your explaining and code. When run the code there is an ERROR: Could not open requirements file: [Errno 2] No such file or directory: 'requirements.txt'. it seems there is no requirement.txt file there

  • @plutophy1242
    @plutophy1242 2 місяці тому +1

    i love ur contents♥

  • @michelspeiser5789
    @michelspeiser5789 10 місяців тому +1

    Instead of argmin on the distance to the closest embedding, couldn't we just use a softmax instead?

  • @yinghaohu8784
    @yinghaohu8784 9 місяців тому

    You mentioned posterior and prior, can you provide some reference, why they model it in this way ?

  • @bdennyw1
    @bdennyw1 3 роки тому

    Love the Pytorch code!

  • @djabort
    @djabort 2 роки тому

    thank you a lot. i like the format with code

  • @НиколайНовичков-е1э

    Great explanation!!! Thank you!

  • @hassenzaayra5419
    @hassenzaayra5419 2 роки тому

    thank you very much for this explanation.
    I would like to know how the creation of the codebook is going

  • @kirtipandya4618
    @kirtipandya4618 3 роки тому +1

    Nice video. Please do more videos like this. 👍🏻

  • @kirtipandya4618
    @kirtipandya4618 3 роки тому +1

    Which software are you using for paper review? One side paper and you can draw and put code next to it.

  • @Jamie-my7lb
    @Jamie-my7lb 3 місяці тому

    Great explanation! You highlighted the most challenging parts of the paper really well. I have one remaining question. VQ-VAE seems identical to a deterministic autoencoder except for the discretization step. Why is discretization so useful? Is it mainly because it effectively compresses information about the image by using a single 7-bit code instead of 128 continuous variables?

  • @terryr9052
    @terryr9052 3 роки тому

    I have been thinking about the VQ-VAE for generating music and it seems to me that one large limitation of quantizing your latent vectors is that you lose the ability to see interesting results that lay between clusters of latent vectors. For example, I train my model on both reggae and death metal songs and the resulting latent space shows two clusters. It would be nice to then hear songs that interpolate between the 2 clusters but it seems that the quantizing step will force any new vectors (our desired hybrid) to adopt the established codebook vectors which are only representative of the "pure" songs. Am I correct in this line of thinking? Has anyone seen any more info on this at all?

  • @deep.extrospection
    @deep.extrospection 3 роки тому +1

    Very good explanation. And with an implementation to support it.
    Thanks a lot!

  • @apollozou9809
    @apollozou9809 2 роки тому

    Overall great explanation. One thing I find confused though. In the paper, loss2 and loss3 are something between Codebook(embeddings vector) and the encoding after CNN. However, in the code, it is something between Quantized encoding after CNN and the encoding after CNN. Can you explain why they are the same thing?

  • @MuhammadAli-mi5gg
    @MuhammadAli-mi5gg 3 роки тому

    Thanks a lot, it was an awesome explanation.
    And yes the code part is necessary as far as I think, and would highly recommend that.
    Moreover, it would be great if you can also make some content regarding these distributions, because I have tried to understand them, but still, they sound quite fuzzy to me.
    Thanks again!

  • @KarimaKadaoui
    @KarimaKadaoui 3 роки тому +1

    Thank you so much for the explanation! I wanted to ask how you get to understand some of the details that are not mentioned in the paper, like how the KL Div ends up being equal to log K?

    • @TheAIEpiphany
      @TheAIEpiphany  3 роки тому

      🙏 Well, analyzing these I bring in my understanding and background from elsewhere to better understand what is going on in this particular paper.

  • @drtristanbehrens
    @drtristanbehrens 2 роки тому

    A great video! Thanks for sharing!

  • @MrMIB983
    @MrMIB983 3 роки тому +5

    Great, we also need VQ-GAN, TransGAN and GANsformer

    • @TheAIEpiphany
      @TheAIEpiphany  3 роки тому +2

      VQ-GAN coming soon as well as DALL-E. I'll add the other 2 to my list. 😂 Thanks!

    • @varunsai9736
      @varunsai9736 3 роки тому +2

      Can you also do clip+ vqgan

    • @TheAIEpiphany
      @TheAIEpiphany  3 роки тому

      @@varunsai9736 Sure I'll see whether I can cram it into VQGAN video

  • @user-my6yf1st8z
    @user-my6yf1st8z 3 роки тому +1

    THANK YOU BROTHER AMAZING

  • @manuobelleiro7711
    @manuobelleiro7711 3 роки тому

    Hello, great video! I had a question regarding the token prediction training. Can this be used to generate images from a text description? If so, where in the code is this implemented? I'm having trouble understanding this last part

  • @sahilgoyal3811
    @sahilgoyal3811 Рік тому

    much helpful!

  • @eranjitkumar11
    @eranjitkumar11 3 роки тому

    Hi, thank you for your work. Can you explain how they incorporate pixelcnn (or wavenet)?

  • @MOSMAIORUM-d2m
    @MOSMAIORUM-d2m 2 роки тому

    Thanks for your amazing&simple explanation. It realy helpful.
    In some paper based on VQVAE, they use perplexity for measurement. But i can not understand what perplexity means in VQVAE model. So if you are not busy can i request explain 'what perplexity means in VQVAE?'
    Thanks again for your wonderful explain!

  • @sarvagyagupta1744
    @sarvagyagupta1744 3 роки тому

    This is a good explanation of VQVAE. I do have a question though. OpenAI's Jukebox is based on VQVAE and they pass gradients through the latent space in their loss function. So is there any difference or what do you think is going on?

  • @hernanperez8427
    @hernanperez8427 3 роки тому

    thanks!! it really likes me, very usefull!

  • @amonkotaro1723
    @amonkotaro1723 Рік тому +1

    the distance looks like (a - b)^2 19:30

  • @johnpope1473
    @johnpope1473 3 роки тому +1

    You’re smashing it. Take some pauses. Pacing conveys a lot / gives space to digest content. Consider you want to cause people to have a light bulb moment. You can’t give people the answer so quickly. I’m looking forward to pytorch stuff. Maybe do some meditation before you record / stillness. Pause.

    • @TheAIEpiphany
      @TheAIEpiphany  3 роки тому

      Thanks for the feedback! I agree I need to work on me being less hectic haha I guess.

  • @peterkonig9537
    @peterkonig9537 2 роки тому +1

    cool video

  • @redone9553
    @redone9553 2 роки тому +1

    Code is nice

  • @abdelrahmanwaelhelaly1871
    @abdelrahmanwaelhelaly1871 3 роки тому

    Thank you

  • @srinathtangudu4899
    @srinathtangudu4899 2 роки тому

    awesome

  • @FlowerHerbert-p4j
    @FlowerHerbert-p4j 3 місяці тому

    Stark Points

  • @AdrianneWeston-o6w
    @AdrianneWeston-o6w 3 місяці тому

    Schowalter Trail

  • @DonteSwell-p4o
    @DonteSwell-p4o 3 місяці тому

    Raynor Stravenue

  • @MacMillanGeoffrey-c8c
    @MacMillanGeoffrey-c8c 3 місяці тому

    Joanne Crest

  • @DobbinBertie-z9u
    @DobbinBertie-z9u 3 місяці тому

    Marcellus Lodge

  • @fullercarey6392
    @fullercarey6392 3 місяці тому

    London Throughway

  • @ToutValentine-z8v
    @ToutValentine-z8v 3 місяці тому

    Walker Light

  • @EstherDiana-h4x
    @EstherDiana-h4x 2 місяці тому

    Carter Brooks

  • @CecilliaDonald-u9f
    @CecilliaDonald-u9f 3 місяці тому

    Dexter Plains

  • @CarlosJones-v9u
    @CarlosJones-v9u 2 місяці тому

    Predovic Ferry

  • @ToneyAshcroft-x5j
    @ToneyAshcroft-x5j 3 місяці тому

    Kieran Alley

  • @jenniferthorndike1574
    @jenniferthorndike1574 2 місяці тому

    Garcia Daniel Martinez Brian Davis Ronald

  • @CherieOvershiner-k3q
    @CherieOvershiner-k3q 3 місяці тому

    Okuneva Junction

  • @PhyllisTuter-z2y
    @PhyllisTuter-z2y 3 місяці тому

    Lockman Island

  • @EdisonUna-n4o
    @EdisonUna-n4o 3 місяці тому

    Angelita Junctions

  • @MonicaZajac-x3v
    @MonicaZajac-x3v 3 місяці тому

    Sarina Island

  • @EleanorMichelson-z6g
    @EleanorMichelson-z6g 3 місяці тому

    Kaylah Harbor

  • @wilhelmbishop4383
    @wilhelmbishop4383 3 місяці тому

    Clark Kenneth Smith Cynthia Rodriguez Edward

  • @JustineKnodel-e6k
    @JustineKnodel-e6k 3 місяці тому

    Olin Plaza

  • @BarrettIda-z5u
    @BarrettIda-z5u 3 місяці тому

    Anita Overpass

  • @MacAdamJay-m2h
    @MacAdamJay-m2h 3 місяці тому

    Eliza Rue

  • @djaym7
    @djaym7 3 роки тому

    +1 on code part

  • @razvanrotaru2285
    @razvanrotaru2285 3 роки тому

    i love you

  • @BrewsterFelix-c4l
    @BrewsterFelix-c4l 3 місяці тому

    Daniel View

  • @JosephThomas-o5x
    @JosephThomas-o5x 3 місяці тому

    Alford Drive

  • @FaradayJack-q2t
    @FaradayJack-q2t 2 місяці тому

    Shields Pine

  • @HansomEden-o1g
    @HansomEden-o1g 3 місяці тому

    Allen Karen Martinez Laura Martin Thomas

  • @HubertCoskrey-l1x
    @HubertCoskrey-l1x 3 місяці тому

    Conroy Spurs

  • @MarkModesty-s9c
    @MarkModesty-s9c 3 місяці тому

    Doyle Walk

  • @ColcloughTammy-e4p
    @ColcloughTammy-e4p 2 місяці тому

    Mandy Mews

  • @MichaelHemingway-j5f
    @MichaelHemingway-j5f 3 місяці тому

    Nienow Roads

  • @RubyStanton-y3i
    @RubyStanton-y3i 3 місяці тому

    Gerlach Spur

  • @VelmaPerea-h6v
    @VelmaPerea-h6v 3 місяці тому

    Fahey Place

  • @KelvinHannah-v5p
    @KelvinHannah-v5p 3 місяці тому

    Cummings Way

  • @CraigBingler-p1z
    @CraigBingler-p1z 3 місяці тому

    Mertz Land

  • @ThereseSproull-x3s
    @ThereseSproull-x3s 3 місяці тому

    Stanton Radial