Essential Matrix Algebra for Neural Networks, Clearly Explained!!!

Поділитися
Вставка
  • Опубліковано 31 тра 2024
  • Although you don't need to know matrix algebra to understand the ideas behind neural networks, if you want to code them or read the latest manuscripts about the field, then you'll need to understand matrix algebra. This video teaches the essential topics in matrix algebra and shows how a neural network can be written as a matrix equation, and then shows how understand PyTorch documentation, error messages and the equations for Attention, which is the fundamental concept behind ChatGPT.
    Note: If you want to learn more about neural networks...
    • The Essential Main Ide...
    ...backpropagation...
    • Neural Networks Pt. 2:...
    ...the ReLU activation function...
    • Neural Networks Pt. 3:...
    ...tensors...
    • Tensors for Neural Net...
    ...SoftMax...
    • Neural Networks Part 5...
    ...Transformers and Attention...
    • Transformer Neural Net...
    If you'd like to support StatQuest, please consider...
    Patreon: / statquest
    ...or...
    UA-cam Membership: / @statquest
    ...buying my book, a study guide, a t-shirt or hoodie, or a song from the StatQuest store...
    statquest.org/statquest-store/
    ...or just donating to StatQuest!
    paypal: www.paypal.me/statquest
    venmo: @JoshStarmer
    Lastly, if you want to keep up with me as I research and create new StatQuests, follow me on twitter:
    / joshuastarmer
    0:00 Awesome song and introduction
    2:35 Introduction to linear transformations
    5:57 Linear transformations in matrix notation
    7:34 Matrix multiplication
    11:03 Matrix multiplication consolidates a sequence of linear transformations
    13: 46 Order matters for matrix multiplication
    15:18 Transposing a matrix
    16:37 Matrix notation and equations
    18:51 Using matrix equations to describe a neural network
    24:26 nn.Linear() documentation explained
    26:38 1-D vs 2-D error messages explained
    27:17 The matrix equation for Attention explained
    #StatQuest #neuralnetworks #matrixalgebra

КОМЕНТАРІ • 130

  • @statquest
    @statquest  6 місяців тому +9

    To learn more about Lightning: lightning.ai/
    Support StatQuest by buying my book The StatQuest Illustrated Guide to Machine Learning or a Study Guide or Merch!!! statquest.org/statquest-store/

    • @bigbacktor
      @bigbacktor 4 місяці тому

      Hi, i would like to buy the book in color. Does someone know if that is posible ? It seems to me that in amazon is in black and white and on Lulu is on color. Is that right ? I am from spain.

    • @statquest
      @statquest  4 місяці тому

      @@bigbacktor They are all in color. And there is a version that is translated into spanish if you are interested.

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

      @@statquest Thanks a lot!! BAM you just sold another book :)

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

      @@bigbacktor Hooray!!! Thank you very much for supporting StatQuest! BAM! :)

  • @bin4ry_d3struct0r
    @bin4ry_d3struct0r 5 місяців тому +12

    All visual learners are blessed by the great Josh Starmer!

  • @user-do2pr3ue9x
    @user-do2pr3ue9x 5 місяців тому +11

    What you do is nothing short of a miracle! Immense gratitude

  • @user-gx9hk8gt3k
    @user-gx9hk8gt3k 5 місяців тому +13

    You have been staying the course for a long, long time. It's not so easy ! Keep up the good work!

  • @kitkitmessi
    @kitkitmessi Місяць тому +3

    this is freaking amazing! Would love to see more math lessons like this

  • @Why_I_am_a_theist
    @Why_I_am_a_theist 5 місяців тому +6

    World is a better place with Josh🎉

  • @free_thinker4958
    @free_thinker4958 4 місяці тому +6

    Could you please make a video about QLORA? ❤ You're our savior when it comes to understanding complex concepts, thank you man

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

      I'll keep that in mind.

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

      that would be lovely, perhaps LORA itself holds a strong glue potential across neural networks, will be looking forward for such amazing video

  • @techproductowner
    @techproductowner 3 місяці тому +2

    You will be known and remembered for the next 1000 years ..

  • @anmolarora2599
    @anmolarora2599 3 місяці тому +2

    Thank you for explaining it so simply even a novice like me can understand it.

  • @haitematik5832
    @haitematik5832 3 місяці тому +2

    Man u deserve a thousand times more subscribers

  • @TheTruthOfAI
    @TheTruthOfAI 3 місяці тому +2

    i love your videos, it helped me so much.. learned a lot.. i was able to make UNA thanks to your learnings :)

    • @statquest
      @statquest  3 місяці тому +1

      Triple bam! Congratulations!

  • @varshinibalaji3535
    @varshinibalaji3535 4 місяці тому +2

    Wow, just the perfect video I was looking for! Loved all the Taylor references, and music puns.

    • @statquest
      @statquest  4 місяці тому

      Hooray!!! You're the first person to mention the Taylor references in a comment. BAM!!! :)

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

      @@statquest I was looking for it, since you mentioned something with Taylor was coming soon, in one of my Linkedin Posts :) Plus, I've been reading a lot of academic papers lately, So needed a better context on matrix transformations to interpret the math better! So, Double BAM, indeed!

  • @user-cf8rq6wk8w
    @user-cf8rq6wk8w 5 місяців тому +4

    Hi Josh... would you please make a video and explain the differences between different statistical tests like t, z, chi... I want to know the differences and when to use each.

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

      I'll keep that in mind.

  • @ShadArfMohammed
    @ShadArfMohammed 5 місяців тому +4

    Baaam this is good :D I have been waiting for this, to be honest, I had the feeling that one day you would make such a tutorial. Your content is great.

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

      Thank you very much!

  • @arenashawn772
    @arenashawn772 5 місяців тому +3

    I found this channel when searching for a clear explanation of central limit theorem on Google (after doing some simulation in R using sample size much less than 30 and being intrigued by the results I got) and I just want to say I love the content so much! (And the ukulele episode ❤) I’ve recently started some machine learning classes on coursera and EdX, and I must say the explanation you have here in these episodes are SO MUCH BETTER AND MORE TO THE POINT/BETTER DEFINED than the multi thousand dollar classes (I’m surely glad I chose to audit them first!) taught by professors from Harvard or Engineers working for Google/IBM. So much better!… ❤❤❤
    Just want to say thank you and Merry Christmas! I know I will be going through these videos one by one in the coming months…

    • @statquest
      @statquest  5 місяців тому +1

      Thank you very much!!! I'm so happy you enjoy my videos. BAM! :)

    • @arenashawn772
      @arenashawn772 5 місяців тому +1

      ⁠@@statquestI really did and binge watched a bunch… But I must say I now enjoy your songs even more 😂 Just bought all your albums on bandcamp - they are awesome! That going back to Cali song just had me rolling off my chairs at the end of it… I relocated from San Francisco Bay Area to Florida panhandle not long ago so that song really struck a cord with me 😂😂😂

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

      @@arenashawn772 Thank you very much! I'm glad you enjoy the tunes and the videos. I hope the move went well! :)

  • @ageofkz
    @ageofkz 3 місяці тому +2

    Really amazing work! This set of videos (neural network playlist) has really helped me in my uni coursework and project! My groupmates and I are planning to get a statquest triple bam hoodie each haha!

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

      That's awesome!!! TRIPLE BAM! :)

  • @ritshpatidar
    @ritshpatidar 5 місяців тому +7

    I was thinking about taking a course to learn matrix algebra yesterday. Thanks for posting this video. It is really helpful and it is like a wish came true.

  • @AyumiFortunex
    @AyumiFortunex 3 місяці тому +2

    Absolutely fantastic explanation again

  • @BrianPondiGeoGeek
    @BrianPondiGeoGeek 5 місяців тому +3

    Tripple Bam for sure. Amazing explanation.

  • @randr10
    @randr10 5 місяців тому +3

    Thank you for this video. I think I understand what a transformer is now.

  • @ilirhajrullahu4083
    @ilirhajrullahu4083 5 місяців тому +6

    Very nice video! Thank you for uploading such helpful material :). It would be great if you made a video on vector and matrix calculus. These are important topics in NNs too :).

    • @statquest
      @statquest  5 місяців тому +1

      I'll keep that in mind.

    • @gocomputing8529
      @gocomputing8529 5 місяців тому +1

      Thanks for the great video! Also the topic proposed here would also be super interesting, so I hope you could do it someday

  • @kartikchaturvedi7868
    @kartikchaturvedi7868 5 місяців тому +2

    Superrrb Awesome Fantastic video

  • @louisnemzer6801
    @louisnemzer6801 5 місяців тому +6

    Squatch: So it's all just matrix multiplication?
    Josh: Always has been

  • @slash_29
    @slash_29 5 місяців тому +3

    Please part 2 with more details, and new terms

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

      I'll keep that in mind.

  • @siddhanthbhattacharyya4206
    @siddhanthbhattacharyya4206 Місяць тому +2

    Quadruple bam! (One bam for me finally understanding)

  • @pran441
    @pran441 5 місяців тому +2

    Joshua your teaching was fantastic, but I couldn't quite grasp the concept.

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

      What time point (minutes and seconds) was confusing?

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

    Quite good. ❤

  • @NJCLM
    @NJCLM 5 місяців тому +4

    Very good video ! You should remake one of the transformer videos with the matrix notation as you done at the end of this vide.

    • @statquest
      @statquest  5 місяців тому +7

      I'm working on it right now. Hopefully it will be ready soon.

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

      @@statquest take your time and thanks you very much, your content is so much valuable !

  • @kujohjotaro3017
    @kujohjotaro3017 5 місяців тому +2

    Your video is just a lifesaver to me and my essay! Could you make a video on the Glove model in NLP?

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

      I'll keep that in mind.

  • @PavanKumar-pt2sh
    @PavanKumar-pt2sh 5 місяців тому +3

    Can you please create a video on multi-modal transformer architecture?

    • @statquest
      @statquest  5 місяців тому +1

      I'll keep that in mind.

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

      I hope he does it, he's our savior when it comes to understanding complex concepts

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

    Hey Josh! I love your channel and I was thinking about buying a study guide. What is the difference between watching one of your playlists and buying a study guide? Do you cover exactly the same in both and buying the study guide is for support/like a donation or is there any difference?

    • @statquest
      @statquest  4 місяці тому

      They are the same. The difference is that some people like to have the study guides for offline use or adding their own notes to. In some ways, the study guides are like "cheat sheets" - everything in a video is condensed to about 3 to 5 pages.

  • @davidmurphy563
    @davidmurphy563 5 місяців тому +3

    Ok, it always annoyed me that when you're doing matrix vector (col) multiplication they always write the matrix first, then the vector. It never occured to me until you said so just now that the cols and rows aren't valid tensor operations if you write them the other way round... Doh! It doesn't look nice though.
    Btw, why did you use a row vector and a transverse matrix? I would always use a col vector. Col space transforms are the default for me and you can picture the latent space.
    The only times I'd use rows is if I have a system of linear equations.

    • @statquest
      @statquest  5 місяців тому +1

      I agree that the matrix * column looks bad. And I chose to do row * matrix because that is what they used in the PyTorch documentation.

    • @davidmurphy563
      @davidmurphy563 5 місяців тому +1

      @@statquestGlad it's not just me that thinks it looks backwards! :)) But you're of course right; 2x2 * 2x1 is a valid operation whereas 2x1 * 2x2 is, strictly speaking, undefined.
      Oh, a tip you may (or may not!) find a useful teaching tool:
      I always look at matrix multiplication in terms of a series of dot product operations. Once the student understands that the dot product outputs a scalar expressing the likeness of two vectors (eg whether two normalised vectors pointing the same way) then rather than just mechanically running an algorithm - the student can see that it's plotting the vector in the new space by comparing its likeness to the space's basis vectors one axis at a time. That's why I think it's always handy to see a square matrix as a series of basis vectors.
      So, if you're going from an orthonormal basis to one where, say, y is mirrored - {{1, 0}, {0, -1}} - then it's quite apparent why taking the dot product for each spatial dimension will plot the vector upside-down. You could show an image flipping to drive the point home.
      I just think that's intuitive and why we're multiplying and adding across columns and rows.
      At least that's how I like to see it.

  • @user-ut3sy6hy4p
    @user-ut3sy6hy4p 2 місяці тому +2

    thanks for ur effort, ur videos helped me so much, but could u plz tell us how lghm works

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

      Do you mean Light Gradient Boost? LightGBM?

    • @user-ut3sy6hy4p
      @user-ut3sy6hy4p 2 місяці тому +1

      I mean LightGBM
      @@statquest

  • @Ahmed_Issaoui
    @Ahmed_Issaoui 4 місяці тому +2

    hello statquest, what software do you use to create your videos ?
    (your answer is really useful to me)

    • @statquest
      @statquest  4 місяці тому

      I give away all of my secrets in this video: ua-cam.com/video/crLXJG-EAhk/v-deo.html

  • @ivant_true
    @ivant_true 5 місяців тому +2

    great

  • @nivcohen961
    @nivcohen961 3 місяці тому +1

    You are awsome

  • @ps3301
    @ps3301 5 місяців тому +3

    Could you explain the math behind a basic liquid neuron and show how it differs from other neuron ?

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

      I'll keep that in mind.

  • @aga5979
    @aga5979 12 днів тому +1

    Could you do a series on "attention is all you need " paper ? Thank you Sir.

    • @statquest
      @statquest  12 днів тому +1

      This video walks you through the concepts in that paper: ua-cam.com/video/zxQyTK8quyY/v-deo.html
      And this video goes through the math: ua-cam.com/video/KphmOJnLAdI/v-deo.html

    • @aga5979
      @aga5979 12 днів тому +1

      @@statquest thank you so much!!

  • @deveshbhatt4063
    @deveshbhatt4063 5 місяців тому +4

    Triple Bam🎉❤

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

    Hi Josh, Could you do video on time series clustering , and time series analysis please?

    • @statquest
      @statquest  4 місяці тому

      I'll keep that in mind.

  • @vigneshvicky6720
    @vigneshvicky6720 5 місяців тому +11

    We want yolo series mainly yolov8 from scratch

    • @statquest
      @statquest  5 місяців тому +2

      I'll keep that in mind.

    • @anickkhan
      @anickkhan 5 місяців тому +2

      Please Professor, it’s an earnest request. Lots of Love from Bangladesh ❤❤

  • @shouvikdey7078
    @shouvikdey7078 5 місяців тому +1

    Do more videos related to GAN etc.

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

      I'll keep that in mind.

  • @user-ob4eh9li9e
    @user-ob4eh9li9e 4 місяці тому +1

    Can u please discuss about stochastic gradient boosting for classification?. I'm having trouble understanding that 😢

    • @statquest
      @statquest  4 місяці тому

      I have a whole series of videos on Gradient Boosting. You can find them here: statquest.org/video-index/

  • @jarsal_firahel
    @jarsal_firahel Місяць тому

    What about a video on MAMBA architecture ? That would be really BAAAM

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

      I'll keep that in mind.

  • @Nono-de3zi
    @Nono-de3zi 5 місяців тому

    Thanks Josh. But naughty, naughty, the stage is not just rotating, it is flipping. Which you can also encode in matrices of course ;-)

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

      I'm not sure I understand what you mean by flipping in addition to rotating as stage left and stage right are maintained through out each change.

    • @Nono-de3zi
      @Nono-de3zi 5 місяців тому

      @@statquest The drawing of the stage is asymmetrical (one edge is slightly erased). When you did the slides you flipped it instead of rotating it. As a result, Statsquatch is sometimes on one side, sometimes on the other. I know it was not on purpose 🙂 Thanks for the excellent vid as usual.

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

      @@Nono-de3zi I'm still confused because statsquach is always on stage left.

    • @Nono-de3zi
      @Nono-de3zi 5 місяців тому

      But the *stage* is flipped :-)

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

      @@Nono-de3zi If it was flipped, then wouldn't stage left stay on top and stage right stay on the bottom?

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

    Can we book on these concepts as well

    • @statquest
      @statquest  4 місяці тому

      I'm writing it right now.

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

    14:05 matrix multiplication cant be rearranged, as matrix multiplication is a sequence of calculations. is this indicated by using X as a multillication symbol and not •? Becaus in school we used • to indicate multiplications.

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

      ah no the x is not signifying order. but I would like that to be visible from writing alone, without the helpful explanation.

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

      i wonder why matrices are turned sideways like that. it would feel easier for me to multiply rows with rows.

    • @statquest
      @statquest  5 місяців тому +1

      This is explained, although I'm guessing not to your satisfaction, at 10:58. It has to do with the ability to combine transformations. For more details, see: math.stackexchange.com/questions/271927/why-historically-do-we-multiply-matrices-as-we-do

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

    BAM!

  • @bossgd100
    @bossgd100 5 місяців тому +1

    Woaw

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

    after 10000000 years, scientists found fossil record of statquest, then he said " BAM!"

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

      Ha! You made me laugh.

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

    Hi, I am trying to start a youtube channel to make tutorial videos about data science related topics. I want to make the videos about things that are less popular but still important, since I found that it can be quite difficult to start off with these things since most information is in difficult to comprehend papers. My starting point will be social network analysis and natural language processing as that is my main interest and expertise. However, I am interested in finding more topics so I am starting by doing research on different channels that make tutorials for data science, AI, machine learning, statistics, natural language processing, graph theory or network analysis.
    So for anybody in the comments that reads this message, could you help me out by replying with any youtube creators that do something related to these topics, or any other digital platform like Brilliant. If you know a topic that is similar to the ones I mentioned that would also be a great thing to share. Or if you know of better places to share this message. Or any other helpfull tips.
    Thanks everybody for the help. If this message is regarded as spam also please say so and I will remove it.
    The topics again:
    -data science
    -AI
    -machine learning
    -statistics
    -natural language processing
    -graph theory
    -network analysis

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

    Great video, but i don't quite understand 25:25...

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

      It just means that PyTorch stores the weights differently than we used in the earlier examples and in order to get the same math, we have to transpose the PyTorch weight matrix.

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

    zhina!

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

    97 videos finished … small bam 🥲