Answers.Body: <p>Batch size affects how many training updates (steps) will happen during each epoch.</p>
  <p>When the batch size is small, this means that the model sees fewer data in each weights update. Thus, your question really depends on the data you have, along with the corresponding task (classification / RL etc.)</p>
  <p>If your data is highly imbalanced, then I would not suggest a small batch size, since the probability of seeing a positive instance would be far smaller (assuming you take uniform batches).</p>
  <p>For an RL task, imagine using a replay buffer of past experiences and your agent had very few good action selections during the only exploration process. Then a small batch size would make the agent training very difficult, since most of the time samples with not good action selections would be seen. As a result, the agent may drift from good policies.</p>
  <p>For a classification task, what I always do, is to make stratified batches. That is each batch has the same label percent as the whole dataset. And most of the time it works for better than uniform batches even for smaller batch sizes. For RL, I would recommend higher batch sizes or similar clever ways of sampling.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-17T01:37:16.173Z
Answers.Text: Task is generative models. I am running GANs. But, according to your answer, can I assume that very small batch sizes leads to poor results?
Answers.UserDisplayName: hanugm
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-17T14:48:10.430Z
Answers.Text: I would prefer bigger sizes. But I think your problem is very data-depending.
Answers.UserDisplayName: ddaedalus
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-05T09:55:52.490Z
Answers.Text: If you think I have helped you with my answer, please check it as correct.
Answers.UserDisplayName: ddaedalus
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-09-05T12:24:36.267Z
Answers.Text: Sure and thanks. I generally upvote and accept nowadays if I understand completely since I may be wrong.
Answers.UserDisplayName: hanugm
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2021-08-16T14:53:14.927Z
Answers.LastActivityDate: 2021-08-16T14:53:14.927Z
Answers.UserDisplayName: ddaedalus
Body: <p>I am trying to run a code that has a batch size around 28. I can run the program on my GPU with this batch size.</p>
  <p>But, when I modify the code for my requirements and try to run, it is showing an run-time error due to insufficient memory in GPU.</p>
  <p>I checked for possible batch-size that I can run and it is just 2-5.</p>
  <p>I am not sure whether there is any issue if I run with such small batch sizes? I mean, will there be any performance issues keeping aside the time it takes?</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2021-09-15T16:22:07.557Z
Comments.Text: there shouldn't be any significant differences. the expected value is the same....
Comments.UserDisplayName: k.c. sayz 'k.c sayz'
Tags: <performance><batch-size>
Title: Will there be any changes in the model's performance due to the usage of very small batch sizes?
UserDisplayName: hanugm
ThreadText: # Will there be any changes in the model's performance due to the usage of very small batch sizes?
  
  (Asked by: username_0 on 2021-08-15)
  
  I am trying to run a code that has a batch size around 28. I can run the program on my GPU with this batch size.
  
  But, when I modify the code for my requirements and try to run, it is showing an run-time error due to insufficient memory in GPU.
  
  I checked for possible batch-size that I can run and it is just 2-5.
  
  I am not sure whether there is any issue if I run with such small batch sizes? I mean, will there be any performance issues keeping aside the time it takes?
  
  **Tags:** performance, batch-size
  > **Comments:**
  > **username_1**: there shouldn't be any significant differences. the expected value is the same....  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2021-08-16. Score: 1
  
  Batch size affects how many training updates (steps) will happen during each epoch.
  
  When the batch size is small, this means that the model sees fewer data in each weights update. Thus, your question really depends on the data you have, along with the corresponding task (classification / RL etc.)
  
  If your data is highly imbalanced, then I would not suggest a small batch size, since the probability of seeing a positive instance would be far smaller (assuming you take uniform batches).
  
  For an RL task, imagine using a replay buffer of past experiences and your agent had very few good action selections during the only exploration process. Then a small batch size would make the agent training very difficult, since most of the time samples with not good action selections would be seen. As a result, the agent may drift from good policies.
  
  For a classification task, what I always do, is to make stratified batches. That is each batch has the same label percent as the whole dataset. And most of the time it works for better than uniform batches even for smaller batch sizes. For RL, I would recommend higher batch sizes or similar clever ways of sampling.
  
  > **Comments:**
  > **username_0**: Task is generative models. I am running GANs. But, according to your answer, can I assume that very small batch sizes leads to poor results?  
  > **username_2**: I would prefer bigger sizes. But I think your problem is very data-depending.  
  > **username_2**: If you think I have helped you with my answer, please check it as correct.  
  > **username_0**: Sure and thanks. I generally upvote and accept nowadays if I understand completely since I may be wrong.  
  
  ---
  
  