[Converge] Larger batch size?

Ref: Effect of batch size on training dynamics

 

  • Don’t decay the learning rate increase the batch size

We can often achieve the benefits of decaying the learning rate by instead increasing the batch size during training.

  • Hypothesis: larger batch sizes don’t generalize as well because the model cannot travel far enough in a reasonable number of training epochs.
  • Finding: better solutions can be far away from the initial weights and if the loss is averaged over the batch then large batch sizes simply do not allow the model to travel far enough to reach the better solutions for the same number of training epochs.

 

 

大家一般都有这样的默认, 调大batch size就要增大学习率, 这是为什么呢?

在比较大batch和小batch时,一般默认都是相同epoch去比较,这样大batch训练iteration次数会更少, 此时如果学习率不做任何调整, 大batch训练更少iteration, 导致拟合程度较低, 精度也会低, 因此需要对学习率做调整, 一个大batch包含样本更多, 避免了小batch包含极端样本的情况, 方差更小, 意味着使用大batch计算下来的梯度方向更可信, 因此可以使用一个更大的learning rate

 

在比较大batch和小batch时,一般默认都是相同epoch去比较,这样大batch训练iteration次数会更少, 此时如果学习率不做任何调整, 大batch训练更少iteration, 导致拟合程度较低, 精度也会低, 因此需要对学习率做调整, 一个大batch包含样本更多, 避免了小batch包含极端样本的情况, 方差更小, 意味着使用大batch计算下来的梯度方向更可信, 因此可以使用一个更大的learning rate

 

盲目增大 Batch_Size 有何坏处?

内存利用率提高了,但是内存容量可能撑不住了。

跑完一次 epoch(全数据集)所需的迭代次数减少,要想达到相同的精度,其所花费的时间大大增加了,从而对参数的修正也就显得更加缓慢。

Batch_Size 增大到一定程度,其确定的下降方向已经基本不再变化。

 

Conclusion: use the default one.

 

 

posted @   郝壹贰叁  阅读(41)  评论(0编辑  收藏  举报
编辑推荐:
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
阅读排行:
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
· 单元测试从入门到精通
· 上周热点回顾(3.3-3.9)
· winform 绘制太阳,地球,月球 运作规律
点击右上角即可分享
微信分享提示