The Wrong Batch Size Will Ruin Your Model

แชร์
ฝัง
  • เผยแพร่เมื่อ 25 ม.ค. 2025

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

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

    If you scale the batch size by the learning rate (i.e. lr=(batch_size/32.)*0.01) then the stochastic gradient descent looks sort of okay here.

    • @underfitted
      @underfitted  2 ปีที่แล้ว

      Interesting :)

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

      I completely agree ... Because the number of updates happening depend on batch size and even the size of the update. So if the learning rate is scaled according to batch size linearly the model can perform very well even with much smaller batches.

  • @agenticmark
    @agenticmark 7 วันที่ผ่านมา

    For me batch size and grad accum make the most difference along with lr scaling

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

    Really like the videos. However, I want to warn against the general statement that a batch size of one is not recommended. It really depends on the problem/data. So don't simply dismiss stochastic gradient descent, try it!

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

      I think that’s fair. I’ve never used it in any of the problems I’ve worked on, but you are right.

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

    Hi! Maybe you can help me with this one: if I want to test an already pre-trained image classifier, how do I proceed regarding the amount of images used? The set containing test images has 100k images, I guess it wouldn't make any sense to load them all at once, so how do I proceed? Thanks!

    • @LucasTheTopG1
      @LucasTheTopG1 21 วันที่ผ่านมา

      could you just load some at a time. Like the first 50, then while that is processing you make a request to get the next 50 while discarding the first 50. Then just repeat? assuming you can get them via a request.

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

    so, what is the optimal batch size?

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

      It depends. Start with 32 and experiment from there.

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

      @@underfitted Does the amount of main memory Ram or GPU ram make a difference? (great videos!)

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

      It does! Your batch has to fit in memory, or it won't work. When you are working with images, for example, you'll quickly find that your batch size can't be too large if you want to fit it in the GPU's memory.

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

    What do you think of (artificially) adding noise to the learning rate. I feel like it used to be more popular to do that, but almost never see it these days.

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

      Yeah… never seen that honestly. I’ve used schedules to decrease the learning rate over time, but never read about adding noise to it.

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

    This is the kind of thing that I hate about deep learning. A single parameter in the optimization method can completely change the results. Batches should be small but not too small. How small? That's for heuristics but will change on different data sets.

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

    Good work, hope your channel gets more attention

    • @underfitted
      @underfitted  2 ปีที่แล้ว

      Thanks, John! It takes time and work but I’ll make it happen.

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

    Hey love this video! Was losing touch of the basics !

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

      Glad it was helpful!

  • @axelanderson2030
    @axelanderson2030 2 ปีที่แล้ว

    If you generate a dummy dataset and set a static learning rate, then smaller batch sizes work better? wtf?

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

    i didnt see a helpful video like this one in the entire internet, thank you ♥

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

    Amazing!!
    Did u know why the batch size os always 32, 64, 128?

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

      I read somewhere about the ability to fit batches in a GPU... can't remember where exactly. That being said, I've seen experiments that show that it really doesn't matter much (if at all.)

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

      It's better for memory usage. GPU, CPU, hard drives, SSD and other in the current 2-bit logic uses memory blocks with sizes of power 2. 2^5 = 32, 2^6=64, 2^7=128 etc. You always want maximum usage of memory. For example you have array with floats, each float will take 32 bits. So, at least it divisible by 32.

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

    Great video man 👏

  • @muhammadtalmeez3276
    @muhammadtalmeez3276 2 ปีที่แล้ว

    Your videos are amazing. Thank you so much for this great knowledge and beautiful videos.

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

      Glad you like them!

  • @ziquaftynny9285
    @ziquaftynny9285 2 ปีที่แล้ว

    I love your presentation style! Very energetic :)

  • @akshay0072
    @akshay0072 8 หลายเดือนก่อน +1

    Good content. Try improving ur way of teaching. Learning should in relaxed tone

    • @underfitted
      @underfitted  8 หลายเดือนก่อน +1

      Thanks! This was an old video. I’ve tried to improve in the latest few.

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

    A new cat video. Cute.

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

    the question is whether if you use a batch and reach the global minimum is your model functionally equivalent to one that didn't batch? Are the weights identical... no they aren't . if your model is generative you don't have equivalence with batch/non batch.