11

I thought that batch size is only for performance. The bigger the batch, more images are computed at the same time to train my net. But I realized, if I change my batch size, my net accuracy gets better. So I did not understand what batch size is. Can someone explain me what is batch size?

4

1 回答 1

19

Caffe 使用Stochastic-Gradient-Descend (SGD)进行训练:也就是说,在每次迭代中,它计算训练数据中参数的(随机)梯度,并在梯度方向上移动(=更改参数)。
现在,如果你用训练数据编写梯度方程,你会注意到,为了准确计算梯度,你需要在每次迭代时评估所有训练数据:这非常耗时,尤其是当训练数据变大时和更大。 为了克服这个问题,SGD 通过采样以随机方式逼近精确梯度
每次迭代只有一小部分训练数据。这小部分是批次。
因此,batch size 越大,每次迭代的梯度估计就越准确。

TL;DR:批量大小会影响每次迭代时估计梯度的准确性,因此更改批量大小会影响优化所采用的“路径”,并可能改变训练过程的结果。


更新:
在 ICLR 2018 会议上,提出了一项有趣的工作:
Samuel L. Smith、Pieter-Jan Kindermans、Chris Ying、Quoc V. Le 不要降低学习率,增加批量大小
这项工作基本上涉及改变批量大小和学习率的影响。

于 2015-11-15T06:32:19.720 回答