Making a New Deep Learning Framework (ML in C Ep.02)

แชร์
ฝัง
  • เผยแพร่เมื่อ 29 ก.ย. 2024

ความคิดเห็น • 117

  • @flflflflflfl
    @flflflflflfl ปีที่แล้ว +49

    23:17 "If you don't really wanna have a fully connected one" ... and then twitch disconnects. AI sure has come a long a way, huh?

  • @brayanalmonte4758
    @brayanalmonte4758 5 หลายเดือนก่อน

    Loving this
    Thank you

  • @shydegenerate77
    @shydegenerate77 ปีที่แล้ว +2

    1:27:19 sometimes it takes femboy to become a good C programmer

  • @urisinger3412
    @urisinger3412 ปีที่แล้ว +46

    i just made one myselsf, took me like 10 hours, idk how you manged to do it in 3 hours, you should try and do the mnist database now

    • @SolathPrime
      @SolathPrime ปีที่แล้ว +1

      it's totally easy it took me 40 minutes
      20 to write the mathematics
      20 to code it

    • @bartpelle3460
      @bartpelle3460 ปีที่แล้ว +1

      @@SolathPrime man people must really like you

    • @urisinger3412
      @urisinger3412 ปีที่แล้ว +1

      @@SolathPrime i dont have any prior expirince, and 40 hours was a big exsteration

    • @evertonsantosdeandradejuni3787
      @evertonsantosdeandradejuni3787 ปีที่แล้ว +24

      @@SolathPrime you're so good, but who asked?

    • @w花b
      @w花b ปีที่แล้ว +1

      I thought about the mnist database but just opening the training set seems like a pain in the arse. Not complicated necessarily if you know how to read files in C but you need to be in a good mood.

  • @bashbarash1148
    @bashbarash1148 ปีที่แล้ว +51

    The amount of your preparation for streams is just crazy. The narration is very smooth, thanks!

  • @Dontrel3030
    @Dontrel3030 ปีที่แล้ว +41

    Can't wait for part 3 to be up on YT to watch it again to actually understand the second half after reading more about it.

  • @fatnassiadam3290
    @fatnassiadam3290 5 หลายเดือนก่อน +4

    As an applied mathematic major student who dream on pursing AI after, i would say this is probably the best thing in TH-cam.

  • @bobtheoutbuilder8552
    @bobtheoutbuilder8552 ปีที่แล้ว +39

    Machine learning in C is very interesting!

  • @carloselfrancos7205
    @carloselfrancos7205 ปีที่แล้ว +10

    You know, in France, we call Twitter "la poubelle d'internet", literally "the garbage bin of internet"... So yeah, it's definitely Twitter

  • @barni_7762
    @barni_7762 ปีที่แล้ว +23

    Am I the only one here who is trying to learn C by watching him code a practical project about a topic I already know?

    • @raphaelmorgan2307
      @raphaelmorgan2307 11 หลายเดือนก่อน +3

      then there's me, who has no interest in C and has coded neural networks before but is just watching this because it's entertaining

    • @barni_7762
      @barni_7762 11 หลายเดือนก่อน

      @@raphaelmorgan2307 Yeah thats also part of the reason I'm here xD

    • @Anonymous-fr2op
      @Anonymous-fr2op 7 หลายเดือนก่อน +2

      No.... don't do that. You would suffer forever. Learn the basics of C separately, and then watch his videos. But if you don't give a F to C, go ahead. I meant, if you aren't planning on using C as your primary language of choice

    • @barni_7762
      @barni_7762 7 หลายเดือนก่อน +5

      @@Anonymous-fr2op I mean I already knew the C basics fairly well with function pointers, typedefs, enums, etc, I just didn't know any design principles for how to actually lay out a big C application. Also ended up learning Rust and it's pretty neat!

    • @Anonymous-fr2op
      @Anonymous-fr2op 7 หลายเดือนก่อน

      ​@@barni_7762yeah,tutorials like these, and some other really help us understand how to write code that is easy to maintain, in that case, you are right

  • @anon_y_mousse
    @anon_y_mousse ปีที่แล้ว +9

    One of the things that I implemented in my own library were some utility functions for allocating multidimensional arrays. What I ended up doing was allocating for two levels of pointers so it could be passed as a pointer to a pointer et cetera to the type, but I allocated everything in one step and then ran it through a loop to patch up the second, third, etc. levels of pointers. All the memory was contiguous, so m[x][y] would work or you could cast the first element's address to a singular pointer to the type. Copying was basically a linearly optimizable operation and you could reference singular elements with array indexing directly. When done it was a single call to free and as long as rows were the same length it could be reallocated with minimal effort as well.
    As for structured types, I use this method from time to time where I do: typedef struct { ...; } TFoo, *PFoo, Foo[1]; and then I can just have all the functions that operate on it take PFoo's and I declare in my functions Foo f; For the various object types in my data structures library I wound up implementing a basic virtual table for objects so I could just describe a given type in function pointers and a tiny bit of data, then generically handle them internally based on that type, _Generic for macros has made some really cool stuff possible with the built-in types too.
    I've never watched anything on Twitch, so I've not seen the previous streams, just what has been posted here, but I hope the next video has you saving the model so you can train it once and just get the results on subsequent iterations. I'm curious how fast it would be if you took a trained model and used it for basic math.

  • @bartoszmaj8691
    @bartoszmaj8691 ปีที่แล้ว +10

    Currently programming my masters degree project in Pytorch, and I can tell you keeping track of sizes continues to be an absolute pain.

  • @swalha1999
    @swalha1999 ปีที่แล้ว +8

    Just wow educational and funny at the same time.
    Thank you very much for this series
    If you have udemy courses I would buy them all

  • @fxs2008
    @fxs2008 ปีที่แล้ว +6

    I'm not sure my comment will be read by the streamer, but here is my hint: you can add extra "1" to all layers input and your bias can be included right into the weights matrix. It will help to remove addition in favor of multiplication. Added at 1:57:20 : It seems your viewer tried to tell you the same idea.

  • @deveshmeena2573
    @deveshmeena2573 ปีที่แล้ว +14

    I am a CS student and I am genuinely impressed by your coding skills. Can you please tell me how to become so good like you? Can you share how & where can we find resources , some good tips etc.

    • @xhivo97
      @xhivo97 ปีที่แล้ว +41

      The answer is always the same, do more projects. The more you code the better you get it just takes a LOT of time.

    • @amitkumargupta-
      @amitkumargupta- ปีที่แล้ว +13

      He codes.

    • @deveshmeena2573
      @deveshmeena2573 ปีที่แล้ว +2

      @@xhivo97 I have experience in building applications. I have also done some free lancing. Now I am contributing into open source projects like Hyperledger. I have this fear of DSA or should i say I don't like doing DSA. I am familiar with data structures but I get bored when I do questions on it but as you know most of the companies require DSA. How can I deal with this?

    • @flflflflflfl
      @flflflflflfl ปีที่แล้ว +9

      ​@@deveshmeena2573 Code more, all day every day. At some point you will start seeing super high level patterns and it will all feel the same, no matter what domain, language, framework, paradigm, etc.

    • @xhivo97
      @xhivo97 ปีที่แล้ว +5

      @@deveshmeena2573 Try to find project for fun but also dedicate a few hours per week to study computer science and maybe a tiny little bit of math. Thing of DSA as a skill, if you master it you can more easily build fun stuf. Also sounds to me like you're on the right track, so just keep at it!

  • @anon-fz2bo
    @anon-fz2bo ปีที่แล้ว +5

    ooga booga software developer

  • @hc3d
    @hc3d ปีที่แล้ว +9

    Just like the first part this ML course is really awesome. Definately the best beginners explanation out there (for programmers with no ML experience).
    Although he is clearly a highly intelligent and capable in the fields of math, programming and ML and teaching, his stream naming skills really suck, in my opinition, the videos really should at least have a part 1-3 suffix. This will be great reference material many years in the future 😄 And he should name his channel "The Ooga Booga Developer/ML Bro/Math Nerd" 😛

  • @bbq1423
    @bbq1423 ปีที่แล้ว +6

    Saw this video once of a guy who stored matrices in both row major and column major at the same time, turns out it's faster to store double the data and have elements beside each other than not.

    • @evertonsantosdeandradejuni3787
      @evertonsantosdeandradejuni3787 ปีที่แล้ว +2

      Wow, that seems new and maybe worth looking into it on different compilers.
      So the reason it's faster is because of L-level cache?
      Perhaps you have a link somewhere about this guy or his implementation?

  • @zedeleyici.1337
    @zedeleyici.1337 หลายเดือนก่อน +1

    it is worth to follow and subscribe you.

  • @chuckbenedict7235
    @chuckbenedict7235 ปีที่แล้ว +3

    Paint crashes when starting to describe matrices...I love this series.

  • @TheSpec90
    @TheSpec90 7 หลายเดือนก่อน +1

    I'm following this videos to reinforce my understanding about machine learning and C, and coding togheter this framework to fix this concepts and also learn and get more familiarized to create stuff like that, thanks for the educating recreational programming sections

  • @filippocucina7001
    @filippocucina7001 ปีที่แล้ว +1

    insane coding this in C language!. will you destroy python as the programming language for Programming?

  • @Anonymous-fr2op
    @Anonymous-fr2op 7 หลายเดือนก่อน +1

    55:55 python itself is written in C 😂😂

  • @matthewpennyroche5192
    @matthewpennyroche5192 4 หลายเดือนก่อน

    Loving this tutorial! Particularly how you say uga buga... I have a comment. You did great work making mat_alloc size independent. However all of your other apis use float as input params. Could you make these api's size independent as well?

  • @dmodmodmodmo
    @dmodmodmodmo ปีที่แล้ว +2

    Why not use ssh -J for jumping directly to the virtual machine

  • @babis6764
    @babis6764 9 หลายเดือนก่อน +1

    That's a weird/unorthodox but correct matrix multiplication.
    Just make the x metric a column vector. It is much easier

  • @rankostevanovich2496
    @rankostevanovich2496 ปีที่แล้ว +4

    Thanks for the content, this channel is a goldmine

  • @armansimonyan5772
    @armansimonyan5772 2 หลายเดือนก่อน

    1:48:00 isn't the amount of cols just 1 always? I mean for each input the output is just a number.

  • @ecosta
    @ecosta ปีที่แล้ว +1

    46:48 - The same reason why I dislike Emscripten or complex code. Also, simple software directly means less space for bugs.

  • @scattermc
    @scattermc 2 หลายเดือนก่อน

    When he says "Essentially, essentially..." you know he bout to cook

  • @pudou_
    @pudou_ ปีที่แล้ว +1

    XOR as example from 13:00 to 21:40:
    sigmoid( [x1 x2] * [w1 w2] + [b1 b2] ) = [a1 a2] ⟶ sigmoid( [a1 a2] * [ w5 ] + [ b3 ] ) = [ a3 ]
    ( [w3 w4] ) ( [ w6 ] )
    Where w5, w6 and b3 are the weights and bias for final AND neuron/gate.
    The final calculation for it would be:
    (NN_INPUT) a0 ⟶ sig[(x1 * w1) + (x2 * w3) + b1] ⟶ a1 ⤵
    (NN_INPUT) a0 ⟶ sig[(x1 * w2) + (x2 * w4) + b2] ⟶ a2 ⟶ sig [(a1 * w5) + (a2 * w6) + b3] -> a3 (NN_OUTPUT)

  • @dewijones92
    @dewijones92 7 หลายเดือนก่อน

    th-cam.com/video/L1TbWe8bVOc/w-d-xo.html
    2:18:39
    what is the key combination you use to edit those 3 lines simultaneously ? thanks

  • @lkda01
    @lkda01 ปีที่แล้ว +1

    you mad bro. 😂

  • @tusharmaurya1668
    @tusharmaurya1668 ปีที่แล้ว +1

    You should make an open source decentralized streaming service in rust.

  • @captainbanglawala2031
    @captainbanglawala2031 ปีที่แล้ว +2

    Love this series. Can you also cover Reinforcement Learning and Transformer neural networks?

    • @barni_7762
      @barni_7762 11 หลายเดือนก่อน

      Damn, it would probably be easier to just flat out write a pytorch clone then... (which isn't actually that hard if you aren't trying to utilize gpu and optimize everything)

  • @tonitch
    @tonitch ปีที่แล้ว +1

    18:50 I'm pretty sure you have switched 21 and 12 there ^^

  • @ovi1326
    @ovi1326 ปีที่แล้ว +1

    I am finally able to memorize matrix multiplication properly thank you sm

  • @azixaka
    @azixaka ปีที่แล้ว +1

    Absolutely superb! Thank you very much!

  • @HazStepFTW
    @HazStepFTW ปีที่แล้ว

    I was once made to feel like an idiot in a coding interview for having a lightweight struct like that and not passing by pointer.

  • @saysoy1
    @saysoy1 ปีที่แล้ว

    i couldn't keep my eyes away from tht bottom bar that folder that is 7.0 GiB that is too much man!

  • @deadmarshal
    @deadmarshal ปีที่แล้ว +3

    99% of ML is done in Fortran actually.

    • @sillymesilly
      @sillymesilly 3 หลายเดือนก่อน

      Makes sense.

  • @emmanuelandre2807
    @emmanuelandre2807 ปีที่แล้ว

    is there a reason why you don't do your mat_alloc by pointer and return a reference instead of a value?

  • @scarysticks66
    @scarysticks66 ปีที่แล้ว

    shouldn't be better to use tensorial notation when you're doing the linear algebra?

  • @Muttisuri
    @Muttisuri ปีที่แล้ว

    I'm here to add to the list of people that are here to inform you that it is indeed a twitter issue.

  • @CameronjrWalker
    @CameronjrWalker ปีที่แล้ว

    Enjoyed the video very much. Last hour you move very quickly through the code and unfortunately it's not always clear on screen? Any chance you would have time to upload to GitHub? Thanks.

  • @easyBob100
    @easyBob100 ปีที่แล้ว

    Could you have put the matrix stuff in it's own file?

  • @nextwave319
    @nextwave319 ปีที่แล้ว

    that differential approximating without symbolic diff was top notch.

  • @silencedspec1711
    @silencedspec1711 ปีที่แล้ว +4

    This reminded me of Joseph Redmon and his DL framework Darknet which is base on C and Cuda. I was curious how he did all his amazing works from this basic level. I am also trying to learn to use C or C++ in future. Great content as always!

    • @alefratat4018
      @alefratat4018 ปีที่แล้ว +8

      Yes, in the early days, we were a lot of engineers / researchers / hackers developping our own DL frameworks, usually in C or C++.
      It was very artisanal and very niche but that was doing the stuff. Definitely the most existing times of my programmer's journey.
      And then, Deep Learning started to attract the big corp and they streamlined the process with their massive manpower leading to the current state: python ecosystem hiding extremely complex codebases with ridiculous amount of abstractions. Anyway, it is as it is.

  • @sgeinok5950
    @sgeinok5950 ปีที่แล้ว

    ayooo what folder does bro have in the bottom of the screen🔥

  • @init1508
    @init1508 ปีที่แล้ว

    Can you do some cyber security videos thx dad

  • @deepfakescoverychannel6710
    @deepfakescoverychannel6710 ปีที่แล้ว

    deadborn

  • @ryumin_217
    @ryumin_217 ปีที่แล้ว

    header only & my machine only library

  • @CaptainBullzAQW
    @CaptainBullzAQW ปีที่แล้ว

    what linux distro is he using?

  • @yogitshankar6348
    @yogitshankar6348 ปีที่แล้ว

    God series orz

  • @SuperNolane
    @SuperNolane ปีที่แล้ว

    right

  • @drygordspellweaver8761
    @drygordspellweaver8761 ปีที่แล้ว

    TsodinFlow?

  • @marcospontes5606
    @marcospontes5606 ปีที่แล้ว

    brilliant

  • @wagsman9999
    @wagsman9999 ปีที่แล้ว

    very interesting

  • @XELER53
    @XELER53 ปีที่แล้ว

    nice coode awesome program

  • @magicsoftwaremsw3927
    @magicsoftwaremsw3927 ปีที่แล้ว

    you are amazing

  • @marloncoutoribeiro1518
    @marloncoutoribeiro1518 ปีที่แล้ว +1

    Thank you very much, Tsoding! Next stop: "back propagation", and then transformers with self-attention, embedding, encoding, decoding and so son :)

  • @namefreenargrom5694
    @namefreenargrom5694 ปีที่แล้ว +3

    Your videos are very very educational. I can't thank you enough for it.
    I have an idea for your next project.
    the KNN algorithm framwork in c
    And maybe in wasm too.
    And make a visualizer that select the nearest neighbors on mouse click.
    The visualiser have to be scalable to 100 000+ points and do it fast.

    • @namefreenargrom5694
      @namefreenargrom5694 ปีที่แล้ว +1

      And probably make hardware that can solve the nearest neighbor very fast using lazers or something like that. Just kiding😄

    • @0xCAFEF00D
      @0xCAFEF00D ปีที่แล้ว

      is this homework?

    • @namefreenargrom5694
      @namefreenargrom5694 ปีที่แล้ว +1

      @@0xCAFEF00D No!. If you relay on poeple on the internet to do your homework you are set to fail.
      I'm just experimenting with the knn for hobby stuff. And would love to see his approch on the subject.
      In case you still think it's homework please make it fast I'm waiting. And it's due next monday.🤣

  • @SolathPrime
    @SolathPrime ปีที่แล้ว +2

    26:26 did you just say uwu?
    I knew it

  • @MR_GREEN1337
    @MR_GREEN1337 ปีที่แล้ว

    but is it viable to implement deep learning models in C ?

  • @mannycalavera121
    @mannycalavera121 ปีที่แล้ว

    RIIR

  • @kubakakauko
    @kubakakauko ปีที่แล้ว +4

    Can you just tell me why? Are you just doing this for a fun project or is there any purpose for reinventing the wheel in C ?

    • @awesomeguy11000
      @awesomeguy11000 ปีที่แล้ว +26

      This whole channel is coding for fun, and when coding is fun its easier to learn.

    • @prenomnom5637
      @prenomnom5637 ปีที่แล้ว +5

      Recreational programming.

    • @Pulsar2000
      @Pulsar2000 ปีที่แล้ว +3

      He said this for serveral times in the video: it's for educational purposes. You have to implement the things by yourself to understand them. Lot of the things he is doing are pretty naive and inefficient. Especially the finite difference function. But that's ok if you just want to demonstrate the basic principles. Modern NN frameworks usually use the autodiff algorithm to calcalute the gradients for the back propagation.

    • @kubakakauko
      @kubakakauko ปีที่แล้ว +2

      @@Pulsar2000 Thank you for the in depth response.

  • @kukfitta2258
    @kukfitta2258 ปีที่แล้ว

    what compiler is this? my clang cant even any of these shet

  • @damnhatesyou
    @damnhatesyou ปีที่แล้ว +1

    I’m gonna try and do this in Haskell.

  • @mentalsquirt1423
    @mentalsquirt1423 ปีที่แล้ว +2

    bro mat_free() please............. it hurts (i'm halfway through so i hope you fix the leaks eventually)

    • @mentalsquirt1423
      @mentalsquirt1423 ปีที่แล้ว +1

      anyway thank you for the 10/10 content keep it up!

    • @mentalsquirt1423
      @mentalsquirt1423 ปีที่แล้ว

      well not relying on the OS to do it for you is a good practice anyway, doesn't your program leave heap alloced memory at exit? i mean, if you use stdlib's exit() that might not be the case, but otherwise are you really that sure that this heap alloced memory is freed anytime before the restart of your machine? if my concerns are not valid in any way, please elaborate, i'd love to hear what you think about it. (i could check with leaks/valgrind ofc but i'm too lazy to do that yet not that lazy to write this somehow)

    • @TsodingDaily
      @TsodingDaily  ปีที่แล้ว +11

      > are you really that sure that this heap alloced memory is freed anytime before the restart of your machine?
      Yes.
      All modern Operating Systems in 2023 deallocate all the memory your program allocated at exit.
      On Linux your C program always calls the exit syscall even if you just return from the main function. That call is generated for you by the compiler. There is literally no other way for the program to stop executing its instructions in the memory except asking the kernel to step in (which is what the exit syscall is for). Without the exit syscall your program continues executing random stuff out of bounds and eventually runs into non-executable pages and gets killed by the kernel resulting in segfault. Which also results in all of the allocated memory being freed.
      Also, just buy more RAM.

    • @thaddaeusmarkle1665
      @thaddaeusmarkle1665 ปีที่แล้ว

      ​@@TsodingDaily so then the main concern with memory leaks is that the program uses up more and more memory the longer the program keeps running... Am I understanding that correctly? So freeing it is still a best practice but not as important for this particular program because it doesn't run for super long. Is that right?